Delivery throughout Europe

Ordered before 16:00 = Shipped today

Fast delivery with DHL

XNUMX days return *


Country

In this project I will show you how to make an RGB LED light that changes color when you press the button.

In this simple project you will learn to change color of an RGB LED with a button. With help from a Arduino UNO

  • Level - Beginner 25% 25%
  • Duration - 10 / 15Min 25% 25%
  • Costs - € 41,42 euros complete 35% 35%

Step 1: Requirements

1X Arduino UNO

1x half loafboard

7X jumper wires

1X RGB LED

1X push buttons

Step 2: Building and Wiring

Now we are going to put the project together. First we connect one of the two GND's of the Arduino to the minus of the breadboard† You connect a 220 ohm resistor to it. Connect the other side of the resistor via a jumper wire to the longest pin of the RGB LED, which is the minus of the LED light. Then you connect the 5 volts through the breadboard on the push button. Diagonally from the button where 5 volts comes in you put a jumper wire that goes to A0. Then you connect a resistor with 220 ohms to the pin of the push button that is vertically below the 5 volt connection. Finally, connect pin 4, 5 and with the other pins of the RGB LED. How you connect these partly determines which color comes first and which comes last. You can also change this in the code.

Step 3: Programming

 

Now that you have finished wiring the project, you can start programming.

It is a relatively simple code, you can adjust it yourself so that it shows a different color pattern than green, blue and red.
But for example purple or yellow.

 

intbutton = 2;
int led1 = 4;
int led2 = 5;
int led3 = 6;
int count = 0;

 

void setup () {

pinMode (2, INPUT);

pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);

}

 

void loop () {

if (digitalRead (2) == LOW) {

count + +;

while (digitalRead (2) == LOW);

}
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, LOW);

if (count == 1) {

digitalWrite (4, HIGH);
digitalWrite (5, LOW);
digitalWrite (6, LOW);

}

if (count == 2) {

digitalWrite (4, LOW);
digitalWrite (5, HIGH);
digitalWrite (6, LOW);

}

if (count == 3) {

digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6, HIGH);

 

}

if (count == 4) {

count = 0;

}

}

This code works but still needs to be adjusted to function ideally.
We leave this to you because you will then really start programming!

 

The rating of www.elektronicavoorjou.nl at WebwinkelKeur Reviews is 9.3/10 based on 4996 reviews.