Angel LED wiring for UNO (6V, 19mm)

Hey guys, long time reader, first time poster. I’ve been googling and testing this to no avail. Can you help?

I want to wire up a simple 5 pin angel led push button switch. I have +,-,C,NO,NC tried numerous sketches and wiring setups but my knowledge is limited and I can’t figure it out.

Each time the switch is pressed I would like it to toggle the led on or off too. For some reason I can’t do it, can someone help me with what I’m missing?

Nothing I have tried comes close to working other than a switch case I got from another post on the programming forum. still doesn’t do what I want but seems like the best approach to the problem.

#include <Bounce2.h>

const int inputPin = 2;    // momentary switch
const int ledPin =  13;      // the number of the LED pin

byte mode = 0;

Bounce bouncer = Bounce();   //setup debounce for first push button

void setup() 
{ pinMode(inputPin, INPUT);
 pinMode(ledPin, OUTPUT);

  bouncer .attach( inputPin );
 bouncer .interval(15);
}

void loop() {
 bouncer.update ( );    // Update the debouncer for the push button
 switch( mode )
 {
   case 0://------------------------ I'm off and in rest mode
     if ( bouncer.read() == HIGH )
     { 
       // switch LED ON
       mode = 1;       
         }
     break;
   case 1://------------------------ I'm in ON mode, wait for key release
     if ( bouncer.read() == LOW )
       mode = 2;
     break;
   case 2://------------------------ I'm ON and in rest mode
     if ( bouncer.read() == HIGH )
     { 
       // switch LED OFF
       mode = 3;
         }
     break;
   case 3://------------------------ I'm in OFF mode, wait for key release
     if ( bouncer.read() == LOW )
       mode = 0;
      break;
 }

}

I want to wire up a simple 5 pin angel led push button switch.

Can you explain what this is please? Maybe a link and a photograph.

Likewise can you post a diagram of how it is wired up. Pencil and paper is fine, Fritzing is not.

Can you say what this code does. Also I am not too sure what you want it to do and why you want to do this.

Green = Normally Open
Blue = Closed
Yellow = Normally Closed

Thanks for your response, do these help?

The code is trying to identify what state the switch is in. I want it to have a 'latching' function and this is what seems most ideal (switch case), I feel like I'm missing one tiny detail. Otherwise I could be overthinking this, not 100%. If this is a stupid way to do this you can tell me, I don't mind.

To explain why I want to do this will take too long now and if I get this working, I will happily post it in detail but the short answer is: I'm making a switch puzzle.

but the short answer is: I'm making a switch puzzle.

OK good enough.

The code is trying to identify what state the switch is in.

Well from the looks of it there can only be two states, but you don't say if it is a latching push button.
Unpressed there will be a connection between Blue and yellow and pressed there will be a connection between Blue and Green.

To make the LED indication a latching one, that is one push to turn it on and another to turn it off you need what is know as a state change detection. There is code that shows you how to do this in the Arduino's IDE. It is under the menu:- File -> Examples -> 02.Digital -> StateChangeDetection

Wire up your switch with the blue going to Ground and the Green going to Pin 2. There is no need to wire up the yellow wire.

In the software enable the internal pull up resistors in the setup function with:-

pinMode(inputPin, INPUT_PULLUP)

Basically you compare the state of the switch as it is now with what it was last time. A push will show up as a logic LOW and un-pushed as HIGH. When the switch reads as LOW and last time you looked it was high it has been pushed and that is when you toggle the state of the LED. Follow this with a simple delay(50) and you won't have to bother with any debounce libiary.

Mike thank you very much!

How do I send this man beer?

SonOfSmokey:
Mike thank you very much!

How do I send this man beer?

:slight_smile: