Project in progress
4x RGB-LED Running Light!

4x RGB-LED Running Light! © Apache-2.0

4 RGB LED's That blink In A Row Of Colors

  • 2,565 views
  • 0 comments
  • 6 respects

Components and supplies

About this project

Code

RGBLEDx4Arduino
    //The Maker Of This Code Allowed Copying! (With Name Mention)
    int sensorPin = A0;   //PotentioMeter Pin
    int redPin1 = 13;     //The Red Pin Of The 1st LED
    int greenPin1 = 12;   //The Green Pin Of The 1st LED
    int bluePin1 = 11;    //The Blue Pin Of The 1st LED
    int redPin2 = 10;     //The Red Pin Of The 2rd LED
    int greenPin2 = 9;    //The Green Pin Of The 2rd LED
    int bluePin2 = 8;     //The Blue Pin Of The 2rd LED
    int redPin3 = 7;      //The Red Pin Of The 3rd LED
    int greenPin3 = 6;    //The Green Pin Of The 3rd LED
    int bluePin3 = 5;     //The Blue Pin Of The 3rd LED
    int redPin4 = 4;      //The Red Pin Of The 4th LED
    int greenPin4 = 3;    //The Green Pin Of The 4th LED
    int bluePin4 = 2;     //The Blue Pin Of The 4th LED
    int sensorValue = 0;  //The Pin Of The Sensor (No Use To It)
    
    //uncomment this line if using a Common Anode LED
    //#define COMMON_ANODE
     
    void setup()
    {
      pinMode(redPin1, OUTPUT);
      pinMode(greenPin1, OUTPUT);
      pinMode(bluePin1, OUTPUT);  
      pinMode(redPin2, OUTPUT);
      pinMode(greenPin2, OUTPUT);
      pinMode(bluePin2, OUTPUT);  
      pinMode(redPin3, OUTPUT);
      pinMode(greenPin3, OUTPUT);
      pinMode(bluePin3, OUTPUT);  
      pinMode(redPin4, OUTPUT);
      pinMode(greenPin4, OUTPUT);
      pinMode(bluePin4, OUTPUT);  
    }
     
    void loop()
    {
      sensorValue = analogRead(sensorPin);
      setColor(255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 0);
      delay(sensorValue);
       sensorValue = analogRead(sensorPin);
      setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 135, 0, 255, 127, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 135, 0, 255, 127, 0, 255, 127, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 135, 0, 255, 127, 0, 255, 127, 0, 255, 127, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(0, 0, 255, 0, 0, 255,  0, 0, 255, 0, 0, 255);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(75, 0, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(75, 0, 130, 75, 0, 130, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(75, 0, 130, 75, 0, 130, 75, 0, 130, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(75, 0, 130, 75, 0, 130,  75, 0, 130, 75, 0, 130);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(148, 0, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(148, 0, 211, 148, 0, 211, 0, 0, 0, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(148, 0, 211, 148, 0, 211, 148, 0, 211, 0, 0, 0);
      delay(sensorValue);
      sensorValue = analogRead(sensorPin);
      setColor(148, 0, 211, 148, 0, 211,  148, 0, 211, 148, 0, 211);
      delay(sensorValue);
    }
     
    void setColor(int red, int green, int blue, int red1, int green1, int blue1, int red2, int green2, int blue2, int red3, int green3, int blue3)
    {
      #ifdef COMMON_ANODE
        red = 255 - red;
        green = 255 - green;
        blue = 255 - blue;
        red1 = 255 - red1;
        green1 = 255 - green1;
        blue1 = 255 - blue1
        red2 = 255 - red2;
        green2 = 255 - green2;
        blue2 = 255 - blue2;
        red3 = 255 - red3;
        green3 = 255 - green3;
        blue3 = 255 - blue3;
      #endif
      analogWrite(redPin1, red);
      analogWrite(greenPin1, green);
      analogWrite(bluePin1, blue); 
      analogWrite(redPin2, red1);
      analogWrite(greenPin2, green1);
      analogWrite(bluePin2, blue1); 
      analogWrite(redPin3, red2);
      analogWrite(greenPin3, green2);
      analogWrite(bluePin3, blue2); 
      analogWrite(redPin4, red3);
      analogWrite(greenPin4, green3);
      analogWrite(bluePin4, blue3); 
       
    }

Schematics

4x_rgb-led_running_light_bb_hb1iN0LHd0.jpg
4x rgb led running light bb hb1in0lhd0

Comments

Similar projects you might like

Light Sequence Creator

Project tutorial by Reid Paulhus

  • 6,407 views
  • 2 comments
  • 16 respects

Arduino Traffic Light Simulator

Project tutorial by Zachary Haslam

  • 8,025 views
  • 1 comment
  • 20 respects

The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

  • 3,530 views
  • 0 comments
  • 14 respects

Controlling LED light intensity using smartphone light senso

Project tutorial by Nikola Travis

  • 2,405 views
  • 0 comments
  • 3 respects

LED as a Light Sensor

Project tutorial by Harsh Dethe

  • 1,773 views
  • 8 comments
  • 17 respects

The Traffic Light

Project tutorial by Tech with Matthew

  • 4,090 views
  • 5 comments
  • 18 respects
Add projectSign up / Login