4 pin led push button

Hi, recently I've purchased this 4 pin led push button, but when I try to use it to turn a LED on and of it doesn't seem to work. This is my code:

int buttonPin = 4;

int buttonState = LOW;

void setup() {
pinMode(buttonPin, INPUT);
pinMode(13, OUTPUT);

void loop() {
buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW); }

What am I doing wrong? (Also how can I controll the light of the button itself?)

What am I doing wrong?

You have either not read or have read and ignored 'how to use this forum - please read'. So please do that and follow the instructions about posting code and images.

In your image it is impossible to tell what is connected to what on the button; which pins are for the LED? Which for the contacts?

You have connected 3 pins of the button. I assume 2 are for the contacts, why have you connected the 3rd but not the 4th?

To use the LED in the button you have to connect it to an output pin and a resistor to ground.

You have connected an LED to an output without a resistor, doing this will probably damage you Uno. You need a resistor in series with the LED, something between about 220 Ohms and 470 Ohms will be fine, the exact value is unimportant.

This is copied from the website you pointed to:

There are two contacts for the button and two contacts for the LED, one marked + and one -. The forward voltage of the LED is about 2.2V so connect a 220 to 1000 ohm resistor in series just as you would with any other LED to your 3V or higher power supply.

So if you can see the + and - marked pins, those are for the led. Use them just as any other led : + to a digital pin from the Arduino (13 if you want), - to a resistor, resistor to GND.

This particular button has a blue body and LED and is latching on/off. The two switch contacts are either connected or disconnected. When you push the button they will switch from one to the other, like an on-off switch. The LED is separated from the button, so you can make it light up when on, light up when off, always lit, etc.

The other pins are for the push button. Connect one side to your pin and the other side to GND.


const int buttonPin = 4;
const int ledPin = 13;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);  // <-- changed here
  pinMode(13, OUTPUT);

void loop() {
  digitalWrite(ledPin , !digitalRead(buttonPin));