Momentary Switch Question

Sounds good, just a couple questions. The toy side of your diagram shows 3 connections. The top goes to the 5v side of the switch, and the bottom to the other side of the switch? The 5v side of the switch branches off prior to the resistor, where is that going?

And any suggestions for SSRs?

btw Thanks everyone for your help.

Itā€™s going to the controller in the Toy itself which reads it and triggers the siren :smiley:

Thatā€™s why you get 5v when you donā€™t press the button .Once itā€™s pressed, the line is effectively connected to ground :smiley:

See the post above. Thereā€™s a link for SSR!

Iā€™m curious how the siren is changed or is there even a different siren for each team? :smiley:

Ahā€¦ice hockey reminds me of ice skating --> Kim Yuna :heart_eyes:

kennethlimcp, this is not a pull-to-ground situation situation since the voltage remains at about 5V even when the button is pressed. I suspect the resistor is to ground and the button pulls to 5V instead. So same idea with the SSR across the button. However, a transistor could be used as well. A PNP 2N3906 would do:

The resistor could be between 33K and 47K if I calculated right.

TheRick, the resistor on the diagram is internal to the toy and ā€œassumedā€ to be there. So when the button is NOT pushed, the toy sees a ground (through the resistor). When the button is pushed, the toy sees +5V, with the resistor limiting the current that flows to ground.

Ah true that! I missed the last part of the sentence

hmm. @TheRick we might need more info cos it's weird the voltage is like .2 V and went back to 5v when the button is pressed

I ordered the SSR that @AndyW suggested. So, hopefully I can incorporate that. Thanks so much everyone for all your help. Iā€™m sure Iā€™ll have more questions when the parts come in and I put everything together.

TheRick, thatā€™s a perfect solution and frankly better than a transistor. Keep us up to date! :ok_hand:

You do not need the resistor or connection to 5V on the toy side, just connect the output of the ssr across the switch terminals.

@AndyW

we are ā€˜making upā€™ whatā€™s on the Toy side and we assume that thereā€™s like a normally high or according to @peekay123 a normally low switch and therefore a pull up/down resistor :smiley:

Like you say just across the switch terminals will do cos the SSR acts like a switch to mimic the mechanical switch

Totally :heartpulse: the SSR! :smiley:

Brilliant! I finally was able to test it today and it worked as advertised. Like @AndyW suggested I just connected the SSR across the switch terminals and now the Red Light turns on when switched to HIGH.

Thanks everyone for your help.

NEXT:

I actually located some source on github from someone who has also attempted this with arduino.


My next step is adapting the source to work with SparkCore. Iā€™m sure Iā€™ll have some questions about that as well once I get around to it.

3 Likes

Hi TheRick,

I had a similar requirement for a parking assistant in my homeā€™s garage. Basically, I needed a sensor (switch) to illuminate an LED for few seconds. I made a working unit originally with a 2n7000 FET a capacitor and a few resistors, which worked great until my kid decided to dismantle it! Plus, it would only extinguish the LED if the switch was open again, so I had to make a cam style trigger for that circuit.

Anyway, I had my Spark laying around, and quickly integrated the existing LED and switch. The Spark lives in a sealed kid proof box now! The switch connection is the basic arduino example, with the 10K resistor to ground on the sensor pin, D0 in my case. The switch also goes to D0 and 5V.

I hope this helps with your project in future. This has the added feature of not caring if the switch is still engaged, or if it was just a quick jab. Obviously wonā€™t help control it via wifi :wink:

void setup()
{  
  pinMode(7,OUTPUT); // LED output
  pinMode(0,INPUT);    // Button input
}

  static unsigned char ledState = LOW;
  static unsigned char buttonState = LOW;
  static unsigned char lastButtonState = LOW;
  static unsigned long ledCameOn = 0;

void loop()
{

  // If the LED has been on for at least 5 seconds then turn it off,
  // regardless of switch state (held in or released)
  if(ledState == HIGH)
  {
    if(millis()-ledCameOn > 5000) // LED illuminates for 5 seconds.
    {
      digitalWrite(7,LOW);
      ledState = LOW;
    }
  }
 // If the button's state has changed, then turn the LED on IF it is not on already.
  buttonState = digitalRead(0);
  if(buttonState != lastButtonState)
  {
    lastButtonState = buttonState;
    if((buttonState == HIGH) && (ledState == LOW))
    {
      digitalWrite(7,HIGH);
      ledState = HIGH;
      ledCameOn = millis();
    }
  }
}

@KegRaider,

Thanks for taking the time to post your code as this will help me with one of my projects where I did not know how to check state of button but, now I do ! :smile: Thanks, Very, Very Much :smile:

I would like to thank all these people in the community for their great help.

I am looking to create an SSR relay board to drive a 24V lawn sprinkler solenoid. My questions are:

  1. Can I use this SSR suggested by Andy? http://www.digikey.com/product-detail/en/AQY280EH/255-2693-ND/646343
  2. What resistance do I need to use on the spark core side to drive the SSR?
  3. I am currently using the saintsmart 2 channel mechanical relay, it has 4 pins 1 VCC 1 GND 2 IN pins, how can I do the same when I am connecting the SSR? I noticed that the SSR has 2 input pins, 1VCC and 1 GND, so how and where could I add the IN pin(s) which will be connected to the Spark Core pins to set one of the Relays on my board to HIGH or LOW?
  4. Last questionā€¦ Can i also use the same SSR to switch 110V light (the specs says that Loan Currents up to 350V)?

Thank you for your help really appreciated.
Mustafa

Hi all,

I ordered the SSR @AndyW suggested. Following @kennethlimcp circuit diagram.

I connected
Sprak Core Side
D2->1K resistor-> SSR pin 1
GND -> SSR pin 2

SSR Side
SSR pin 3 -> +5V -> 360 resistor -> + RED led
SSR pin 3 -> GND -> - RED led

The LED turns on as soon as i connect the 5V power source. When I turn D2 to High or Low, the LED doesnā€™t turn on or off.

where might my error be? Sorry I have SW background and new to the HW game.

Thank for your help appreciate it

It should beā€¦

5V --> Red LED + ā€”> resistor ----> Red LED - ----> SSR pin 3

SSR pin 4 ā€”> gnd

@kennethlimcp thank for the quick reply!! it worked like a charm :slight_smile:

1 Like