RGB Disco Light

by MrMagic in Circuits > LEDs

586 Views, 6 Favorites, 0 Comments

RGB Disco Light

image_6483441 (1).JPG

In this project, I will show you how to create a rainbow disco light with just some wires, code, and an RGB.

Supplies

image_123923953 (1).JPG

You will need

  1. 1 USB Cable for Arduino
  2. 4 Male-to-Male wires
  3. 3 220/330 Ohm Resistors (Either one works)
  4. 1 RGB Led
  5. 1 Arduino Uno R3
  6. 1 Breadboard Mini

Wiring

Screenshot 2022-06-03 8.56.14 AM.png

First, we're going to need to wire the circuit. You can use the steps below, or follow the picture I have attached.

  1. Red wire from pin ~6 to hole 6 on bottom row breadboard mini.
  2. Black wire from GND to hole 7 on top row of breadboard mini.
  3. Green wire from pin ~5 to hole 8 on bottom row of breadboard mini.
  4. Blue wire from pin ~3 to hole 9 on bottom row of breadboard mini
  5. Resistor from hole 6 on bottom row to hole 6 on top row.
  6. Resistor from hole 8 on bottom row to hole 8 on top row.
  7. Resistor from hole 9 on bottom row to hole 9 on top row.
  8. Line up cathode (longest prong of RGB led) with the black wire, and the rest of the prongs should line up with the resistors.
  9. Upload code (on next step).

Uploading the Code

Open up the arduino cloud editor, and open a new sketch.

Then, copy the code below, and paste it into the new sketch.

After you do that, plug in the usb cable to the arduino and then into your PC/Chromebook. Upload the code and

your done! Enjoy!

#define BLUE 3

#define GREEN 5

#define RED 6


void setup()

{

 pinMode(RED, OUTPUT);

 pinMode(GREEN, OUTPUT);

 pinMode(BLUE, OUTPUT);

 digitalWrite(RED, HIGH);

 digitalWrite(GREEN, LOW);

 digitalWrite(BLUE, LOW);

}


int redValue;

int greenValue;

int blueValue;


void loop()

{

#define delayTime 1 //You can change this delay time to be whatever you want, 1 being the fastest!


 redValue = 255;

 greenValue = 0;

 blueValue = 0;

 for (int i = 0; i < 255; i += 1) 

 {

  redValue -= 1;

  greenValue += 1;

  analogWrite(RED, redValue);

  analogWrite(GREEN, greenValue);

  delay(delayTime);

 }


 redValue = 0;

 greenValue = 255;

 blueValue = 0;


 for (int i = 0; i < 255; i += 1) 

 {

  greenValue -= 1;

  blueValue += 1;

  analogWrite(GREEN, greenValue);

  analogWrite(BLUE, blueValue);

  delay(delayTime);

 }


 redValue = 0;

 greenValue = 0;

 blueValue = 255;


 for (int i = 0; i < 255; i += 1) 

 {

  blueValue -= 1;

  redValue += 1;

  analogWrite(BLUE, blueValue);

  analogWrite(RED, redValue);

  delay(delayTime);

 }

}

Testing the RGB Led

image_6483441 (1).JPG