r/arduino • u/Constant_Ad5593 • 8d ago
Beginner Arduino RGB Painter Project Not Working (Tinkercad)
Hello everyone,
I recently started learning Arduino and decided to build a small RGB “painter” project in Tinkercad. The idea is to use 3 buttons to control an RGB LED: each button corresponds to one color channel (red, green, or blue), and when the use presses a button, that color should light up.
However, my circuit still doesn’t work properly, and I genuinely cannot figure out why after spending hours debugging it. 😭 I checked the pins, wiring, code, and button logic multiple times, but I’m still getting strange behavior from the RGB LED.
I’ve uploaded screenshots of both the circuit and the schematic, along with the code. I would really appreciate any help or suggestions on what might be wrong. Thank you!
int pin_red_button = 4;
int pin_green_button = 3;
int pin_blue_button = 2;
int pin_blue_led = 5;
int pin_red_led = 6;
int pin_green_led = 10;
void setup()
{
pinMode (pin_red_button, INPUT_PULLUP);
pinMode (pin_blue_button, INPUT_PULLUP);
pinMode (pin_green_button, INPUT_PULLUP);
pinMode(pin_green_led, OUTPUT);
pinMode(pin_red_led, OUTPUT);
pinMode(pin_blue_led, OUTPUT);
}
void loop()
{
int button_state_red = digitalRead(pin_red_button);
int button_state_green = digitalRead(pin_green_button);
int button_state_blue = digitalRead(pin_blue_button);
if (button_state_blue == LOW) {
analogWrite (pin_blue_led, 255);
}
else {
analogWrite (pin_blue_led, 0);
}
if (button_state_red == LOW) {
analogWrite (pin_red_led, 255);
}
else {
analogWrite (pin_red_led, 0);
}
if (button_state_green == LOW) {
analogWrite (pin_green_led, 255);
}
else {
analogWrite (pin_green_led, 0);
}
}



3
u/ripred3 My other dev board is a Porsche 8d ago
I agree with u/Delta_G_Robotics we need some more detail.
Your code looks fine. The connection diagram is drawn wrong and/or you have overlapping wires which prevent us from being able to tell if things are connected properly. Two examples are that the input wires going to each individual button are not clear in the breadboard diagram. The schematic showing how you are using the buttons is rendered incorrectly (possibly with overlapping wires which make some parts unclear). and one side of the buttons/switches are shown as complete isolated loops which is wrong. But that also does not match your breadboard illustration so hopefully it is actually wired correctly and it is something more simple like the button legs not making good contact or other common problems.
3
u/Delta_G_Robotics 8d ago
When you say, "strange behavior", what do you actually mean. I can't see it.