you need this components.
1 . arduino uno.
2 RGB light.
3 some jumper wire.
4. 3 risistor 270 OM.
code.
/* Adafruit Arduino - Lesson 3. RGB */
int redPin = 11; int greenPin = 10; int bluePin = 9;
//uncomment this line if using a //#define COMMON_ANODE
void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); }
void loop() { setColor(255, 0, 0); // red delay(1000); setColor(0, 255, 0); // green delay(1000); setColor(0, 0, 255); // blue delay(1000); setColor(255, 255, 0); // yel delay(1000); setColor(80, 0, 80); // purple delay(1000); setColor(0, 255, 255); // aqu delay(1000); }
void setColor(int red, int green { #ifdef COMMON_ANODE red = 255 - red; green = 255 - green; blue = 255 - blue; #endif analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue); }
1 . arduino uno.
2 RGB light.
3 some jumper wire.
4. 3 risistor 270 OM.
code.
/* Adafruit Arduino - Lesson 3. RGB */
int redPin = 11; int greenPin = 10; int bluePin = 9;
//uncomment this line if using a //#define COMMON_ANODE
void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); }
void loop() { setColor(255, 0, 0); // red delay(1000); setColor(0, 255, 0); // green delay(1000); setColor(0, 0, 255); // blue delay(1000); setColor(255, 255, 0); // yel delay(1000); setColor(80, 0, 80); // purple delay(1000); setColor(0, 255, 255); // aqu delay(1000); }
void setColor(int red, int green { #ifdef COMMON_ANODE red = 255 - red; green = 255 - green; blue = 255 - blue; #endif analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue); }
full connection arduino RGB light
No comments:
Post a Comment