Components and supplies
1
Jumper wires (generic)
1
Single Turn Potentiometer- 10k ohms
1
RGB Diffused Common Cathode
1
Resistor 221 ohm
1
Breadboard (generic)
1
Arduino UNO
Project description
Code
RGBLEDx4
arduino
1 //The Maker Of This Code Allowed Copying! (With Name Mention) 2 int sensorPin = A0; //PotentioMeter Pin 3 int redPin1 = 13; //The Red Pin Of The 1st LED 4 int greenPin1 = 12; //The Green Pin Of The 1st LED 5 int bluePin1 = 11; //The Blue Pin Of The 1st LED 6 int redPin2 = 10; //The Red Pin Of The 2rd LED 7 int greenPin2 = 9; //The Green Pin Of The 2rd LED 8 int bluePin2 = 8; //The Blue Pin Of The 2rd LED 9 int redPin3 = 7; //The Red Pin Of The 3rd LED 10 int greenPin3 = 6; //The Green Pin Of The 3rd LED 11 int bluePin3 = 5; //The Blue Pin Of The 3rd LED 12 int redPin4 = 4; //The Red Pin Of The 4th LED 13 int greenPin4 = 3; //The Green Pin Of The 4th LED 14 int bluePin4 = 2; //The Blue Pin Of The 4th LED 15 int sensorValue = 0; //The Pin Of The Sensor (No Use To It) 16 17 //uncomment this line if using a Common Anode LED 18 //#define COMMON_ANODE 19 20 void setup() 21 { 22 pinMode(redPin1, OUTPUT); 23 pinMode(greenPin1, OUTPUT); 24 pinMode(bluePin1, OUTPUT); 25 pinMode(redPin2, OUTPUT); 26 pinMode(greenPin2, OUTPUT); 27 pinMode(bluePin2, OUTPUT); 28 pinMode(redPin3, OUTPUT); 29 pinMode(greenPin3, OUTPUT); 30 pinMode(bluePin3, OUTPUT); 31 pinMode(redPin4, OUTPUT); 32 pinMode(greenPin4, OUTPUT); 33 pinMode(bluePin4, OUTPUT); 34 } 35 36 void loop() 37 { 38 sensorValue = analogRead(sensorPin); 39 setColor(255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 40 delay(sensorValue); 41 sensorValue = analogRead(sensorPin); 42 setColor(255, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0); 43 delay(sensorValue); 44 sensorValue = analogRead(sensorPin); 45 setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 0); 46 delay(sensorValue); 47 sensorValue = analogRead(sensorPin); 48 setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0); 49 delay(sensorValue); 50 sensorValue = analogRead(sensorPin); 51 setColor(255, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 52 delay(sensorValue); 53 sensorValue = analogRead(sensorPin); 54 setColor(255, 135, 0, 255, 127, 0, 0, 0, 0, 0, 0, 0); 55 delay(sensorValue); 56 sensorValue = analogRead(sensorPin); 57 setColor(255, 135, 0, 255, 127, 0, 255, 127, 0, 0, 0, 0); 58 delay(sensorValue); 59 sensorValue = analogRead(sensorPin); 60 setColor(255, 135, 0, 255, 127, 0, 255, 127, 0, 255, 127, 0); 61 delay(sensorValue); 62 sensorValue = analogRead(sensorPin); 63 setColor(255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 64 delay(sensorValue); 65 sensorValue = analogRead(sensorPin); 66 setColor(255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0); 67 delay(sensorValue); 68 sensorValue = analogRead(sensorPin); 69 setColor(255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0); 70 delay(sensorValue); 71 sensorValue = analogRead(sensorPin); 72 setColor(255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0); 73 delay(sensorValue); 74 sensorValue = analogRead(sensorPin); 75 setColor(0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 76 delay(sensorValue); 77 sensorValue = analogRead(sensorPin); 78 setColor(0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0); 79 delay(sensorValue); 80 sensorValue = analogRead(sensorPin); 81 setColor(0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 0); 82 delay(sensorValue); 83 sensorValue = analogRead(sensorPin); 84 setColor(0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0); 85 delay(sensorValue); 86 sensorValue = analogRead(sensorPin); 87 setColor(0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0); 88 delay(sensorValue); 89 sensorValue = analogRead(sensorPin); 90 setColor(0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0); 91 delay(sensorValue); 92 sensorValue = analogRead(sensorPin); 93 setColor(0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0); 94 delay(sensorValue); 95 sensorValue = analogRead(sensorPin); 96 setColor(0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255); 97 delay(sensorValue); 98 sensorValue = analogRead(sensorPin); 99 setColor(75, 0, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0); 100 delay(sensorValue); 101 sensorValue = analogRead(sensorPin); 102 setColor(75, 0, 130, 75, 0, 130, 0, 0, 0, 0, 0, 0); 103 delay(sensorValue); 104 sensorValue = analogRead(sensorPin); 105 setColor(75, 0, 130, 75, 0, 130, 75, 0, 130, 0, 0, 0); 106 delay(sensorValue); 107 sensorValue = analogRead(sensorPin); 108 setColor(75, 0, 130, 75, 0, 130, 75, 0, 130, 75, 0, 130); 109 delay(sensorValue); 110 sensorValue = analogRead(sensorPin); 111 setColor(148, 0, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0); 112 delay(sensorValue); 113 sensorValue = analogRead(sensorPin); 114 setColor(148, 0, 211, 148, 0, 211, 0, 0, 0, 0, 0, 0); 115 delay(sensorValue); 116 sensorValue = analogRead(sensorPin); 117 setColor(148, 0, 211, 148, 0, 211, 148, 0, 211, 0, 0, 0); 118 delay(sensorValue); 119 sensorValue = analogRead(sensorPin); 120 setColor(148, 0, 211, 148, 0, 211, 148, 0, 211, 148, 0, 211); 121 delay(sensorValue); 122 } 123 124 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) 125 { 126 #ifdef COMMON_ANODE 127 red = 255 - red; 128 green = 255 - green; 129 blue = 255 - blue; 130 red1 = 255 - red1; 131 green1 = 255 - green1; 132 blue1 = 255 - blue1 133 red2 = 255 - red2; 134 green2 = 255 - green2; 135 blue2 = 255 - blue2; 136 red3 = 255 - red3; 137 green3 = 255 - green3; 138 blue3 = 255 - blue3; 139 #endif 140 analogWrite(redPin1, red); 141 analogWrite(greenPin1, green); 142 analogWrite(bluePin1, blue); 143 analogWrite(redPin2, red1); 144 analogWrite(greenPin2, green1); 145 analogWrite(bluePin2, blue1); 146 analogWrite(redPin3, red2); 147 analogWrite(greenPin3, green2); 148 analogWrite(bluePin3, blue2); 149 analogWrite(redPin4, red3); 150 analogWrite(greenPin4, green3); 151 analogWrite(bluePin4, blue3); 152 153 }
RGBLEDx4
arduino
1 //The Maker Of This Code Allowed Copying! (With Name Mention) 2 3 int sensorPin = A0; //PotentioMeter Pin 4 int redPin1 = 13; //The 5 Red Pin Of The 1st LED 6 int greenPin1 = 12; //The Green Pin Of The 1st LED 7 8 int bluePin1 = 11; //The Blue Pin Of The 1st LED 9 int redPin2 = 10; 10 //The Red Pin Of The 2rd LED 11 int greenPin2 = 9; //The Green Pin Of 12 The 2rd LED 13 int bluePin2 = 8; //The Blue Pin Of The 2rd LED 14 int 15 redPin3 = 7; //The Red Pin Of The 3rd LED 16 int greenPin3 = 6; //The 17 Green Pin Of The 3rd LED 18 int bluePin3 = 5; //The Blue Pin Of The 3rd 19 LED 20 int redPin4 = 4; //The Red Pin Of The 4th LED 21 int greenPin4 22 = 3; //The Green Pin Of The 4th LED 23 int bluePin4 = 2; //The Blue Pin 24 Of The 4th LED 25 int sensorValue = 0; //The Pin Of The Sensor (No Use To It) 26 27 28 //uncomment this line if using a Common Anode LED 29 //#define COMMON_ANODE 30 31 32 void setup() 33 { 34 pinMode(redPin1, OUTPUT); 35 pinMode(greenPin1, 36 OUTPUT); 37 pinMode(bluePin1, OUTPUT); 38 pinMode(redPin2, OUTPUT); 39 40 pinMode(greenPin2, OUTPUT); 41 pinMode(bluePin2, OUTPUT); 42 pinMode(redPin3, 43 OUTPUT); 44 pinMode(greenPin3, OUTPUT); 45 pinMode(bluePin3, OUTPUT); 46 47 pinMode(redPin4, OUTPUT); 48 pinMode(greenPin4, OUTPUT); 49 pinMode(bluePin4, 50 OUTPUT); 51 } 52 53 void loop() 54 { 55 sensorValue = 56 analogRead(sensorPin); 57 setColor(255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 58 59 delay(sensorValue); 60 sensorValue = analogRead(sensorPin); 61 setColor(255, 62 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0); 63 delay(sensorValue); 64 sensorValue 65 = analogRead(sensorPin); 66 setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 67 0); 68 delay(sensorValue); 69 sensorValue = analogRead(sensorPin); 70 71 setColor(255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0); 72 delay(sensorValue); 73 74 sensorValue = analogRead(sensorPin); 75 setColor(255, 135, 0, 0, 0, 76 0, 0, 0, 0, 0, 0, 0); 77 delay(sensorValue); 78 sensorValue = analogRead(sensorPin); 79 80 setColor(255, 135, 0, 255, 127, 0, 0, 0, 0, 0, 0, 0); 81 delay(sensorValue); 82 83 sensorValue = analogRead(sensorPin); 84 setColor(255, 135, 0, 255, 127, 85 0, 255, 127, 0, 0, 0, 0); 86 delay(sensorValue); 87 sensorValue = analogRead(sensorPin); 88 89 setColor(255, 135, 0, 255, 127, 0, 255, 127, 0, 255, 127, 0); 90 delay(sensorValue); 91 92 sensorValue = analogRead(sensorPin); 93 setColor(255, 255, 0, 0, 0, 94 0, 0, 0, 0, 0, 0, 0); 95 delay(sensorValue); 96 sensorValue = analogRead(sensorPin); 97 98 setColor(255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0); 99 delay(sensorValue); 100 101 sensorValue = analogRead(sensorPin); 102 setColor(255, 255, 0, 255, 255, 103 0, 255, 255, 0, 0, 0, 0); 104 delay(sensorValue); 105 sensorValue = analogRead(sensorPin); 106 107 setColor(255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0); 108 delay(sensorValue); 109 110 sensorValue = analogRead(sensorPin); 111 setColor(0, 255, 0, 0, 0, 0, 112 0, 0, 0, 0, 0, 0); 113 delay(sensorValue); 114 sensorValue = analogRead(sensorPin); 115 116 setColor(0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0); 117 delay(sensorValue); 118 119 sensorValue = analogRead(sensorPin); 120 setColor(0, 255, 0, 0, 255, 121 0, 0, 255, 0, 0, 0, 0); 122 delay(sensorValue); 123 sensorValue = analogRead(sensorPin); 124 125 setColor(0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0); 126 delay(sensorValue); 127 128 sensorValue = analogRead(sensorPin); 129 setColor(0, 0, 255, 0, 0, 0, 130 0, 0, 0, 0, 0, 0); 131 delay(sensorValue); 132 sensorValue = analogRead(sensorPin); 133 134 setColor(0, 0, 255, 0, 0, 255, 0, 0, 0, 0, 0, 0); 135 delay(sensorValue); 136 137 sensorValue = analogRead(sensorPin); 138 setColor(0, 0, 255, 0, 0, 255, 139 0, 0, 255, 0, 0, 0); 140 delay(sensorValue); 141 sensorValue = analogRead(sensorPin); 142 143 setColor(0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255); 144 delay(sensorValue); 145 146 sensorValue = analogRead(sensorPin); 147 setColor(75, 0, 130, 0, 0, 0, 148 0, 0, 0, 0, 0, 0); 149 delay(sensorValue); 150 sensorValue = analogRead(sensorPin); 151 152 setColor(75, 0, 130, 75, 0, 130, 0, 0, 0, 0, 0, 0); 153 delay(sensorValue); 154 155 sensorValue = analogRead(sensorPin); 156 setColor(75, 0, 130, 75, 0, 157 130, 75, 0, 130, 0, 0, 0); 158 delay(sensorValue); 159 sensorValue = analogRead(sensorPin); 160 161 setColor(75, 0, 130, 75, 0, 130, 75, 0, 130, 75, 0, 130); 162 delay(sensorValue); 163 164 sensorValue = analogRead(sensorPin); 165 setColor(148, 0, 211, 0, 0, 166 0, 0, 0, 0, 0, 0, 0); 167 delay(sensorValue); 168 sensorValue = analogRead(sensorPin); 169 170 setColor(148, 0, 211, 148, 0, 211, 0, 0, 0, 0, 0, 0); 171 delay(sensorValue); 172 173 sensorValue = analogRead(sensorPin); 174 setColor(148, 0, 211, 148, 0, 175 211, 148, 0, 211, 0, 0, 0); 176 delay(sensorValue); 177 sensorValue = 178 analogRead(sensorPin); 179 setColor(148, 0, 211, 148, 0, 211, 148, 0, 211, 180 148, 0, 211); 181 delay(sensorValue); 182 } 183 184 void setColor(int 185 red, int green, int blue, int red1, int green1, int blue1, int red2, int green2, 186 int blue2, int red3, int green3, int blue3) 187 { 188 #ifdef COMMON_ANODE 189 190 red = 255 - red; 191 green = 255 - green; 192 blue = 255 - 193 blue; 194 red1 = 255 - red1; 195 green1 = 255 - green1; 196 blue1 197 = 255 - blue1 198 red2 = 255 - red2; 199 green2 = 255 - green2; 200 201 blue2 = 255 - blue2; 202 red3 = 255 - red3; 203 green3 = 255 204 - green3; 205 blue3 = 255 - blue3; 206 #endif 207 analogWrite(redPin1, 208 red); 209 analogWrite(greenPin1, green); 210 analogWrite(bluePin1, blue); 211 212 analogWrite(redPin2, red1); 213 analogWrite(greenPin2, green1); 214 215 analogWrite(bluePin2, blue1); 216 analogWrite(redPin3, red2); 217 analogWrite(greenPin3, 218 green2); 219 analogWrite(bluePin3, blue2); 220 analogWrite(redPin4, red3); 221 222 analogWrite(greenPin4, green3); 223 analogWrite(bluePin4, blue3); 224 225 226 }
Downloadable files
4x_rgb-led_running_light_bb_hb1iN0LHd0.jpg
4x_rgb-led_running_light_bb_hb1iN0LHd0.jpg

Comments
Only logged in users can leave comments