I have no idea why this isn't working :(

|500x321

//this is my code int redButton = 13; int greenButton = 12; int blueButton = 11; int redLed = 4; int greenLed = 3; int blueLed = 2; int buttonStateRed = 0; int buttonStateGreen = 0; int buttonStateBlue = 0;

void setup(){ pinMode(redButton, INPUT); pinMode(greenButton, INPUT); pinMode(blueButton, INPUT); pinMode(redLed, OUTPUT); pinMode(greenLed, OUTPUT); pinMode(blueLed, OUTPUT); }

void loop(){ buttonStateRed = digitalRead(redButton); buttonStateGreen = digitalRead(greenButton); buttonStateBlue = digitalRead(blueButton); if(buttonStateRed == HIGH){ digitalWrite(redLed, HIGH); } else if(buttonStateGreen == HIGH){ digitalWrite(greenLed, HIGH); } else if(buttonStateBlue == HIGH){ digitalWrite(blueLed, HIGH); } else{ digitalWrite(redLed, LOW); digitalWrite(greenLed, LOW); digitalWrite(blueLed, LOW); } }

I have no idea why this isn’t working :frowning:

Nor do we… you at least have the advantage of knowing what it’s supposed to do, which you didn’t share with us. Nor do we know what it is doing…

Code in code tags (the </> icon) not quotes.

Wild guess: the square switches if that is indeed what you used, may need a quarter turn on the board. You might not be switching anything, due to the way they work inside. Easiest way to be safe, is connect the wires to be switched, diagonally opposite each other: the diagonals always switch.

(Nobody here likes Fritzing pix: proper schematics are much preferred.)

14 LED's on each output pin with no resistors is a sure fire way to fry your Arduino.

You need a resistor for each LED to prevent the LED from burning out.(Actually 3 one for each color of each RGB)

The Arduino cannot provide enough power for that many LED's. you will need a separate power source for them and a transistor on each output pin to control them.

pardon me, but it IS working, and working exactly as you programed it.

if you are not happy about the WAY it is working and want it to work a different way.... with that, we can help.

as I see your code if the red led button/switch is pressed then turn on the red led if it is not pressed, turn on the green, turn on the blue, turn off the red.

so, based on your code, the blue and green are always on. the red goes on and off with the button press.

since you have other buttons, you might want to allow the program to turn off the blue and green ? just guessing, of course.

if you want to fade them, you might want to use the pins that can do pwm.

JimboZA: Wild guess: the square switches if that is indeed what you used, may need a quarter turn on the board.

I think you will find that you cannot.

The pin arrangement is not square, it is 0.2" in one direction, and 0.3" in the other, only the latter will bridge the breadboard furrow.

Paul__B: I think you will find that you cannot.

The pin arrangement is not square, it is 0.2" in one direction, and 0.3" in the other, only the latter will bridge the breadboard furrow.

if the switch is working, then great. if the switch is not, then a check if the two short side are common, or the two long side are common. I have had both. so physical views do not automatically represent continuity of pins.

Hi,
Have you got a DMM to check some voltages?

Tom… :slight_smile:

It would be be good to get more info from OP.... then we can give some meaningful help