This program blinks a multi-color LED
through the colors Red, Blue and Green. The multi-color LED actually three LEDs
- A Red, Green and Blue LED. Other colors are possible since combinations of
colors and mixing of colors are seen as new colors.
This program blinks a multi-color LED
through the colors Red, Blue and Green. The multi-color LED actually three LEDs
- A Red, Green and Blue LED. Other colors are possible since combinations of
colors and mixing of colors are seen as new colors.
NOTE: The Green lead of the LED (G) is located on the right side of the connection diagram above (connections matter!).
NOTE: Some Multi-color LEDs connections can vary from the connection diagram above and you may need to connect the leads differently than shown above.
Challenge: make the LED blink through the colors Red, Orange, Yellow, Green, Cyan, and Blue
--------------------------- Copy Code Below
void setup()
{
pinMode(8, OUTPUT); //Red
pinMode(9, OUTPUT); //Green
pinMode(10, OUTPUT);
//Blue
}
void loop()
{
digitalWrite(8, HIGH); //Red
ON
delay(1000);
digitalWrite(8, LOW); //Red
OFF
digitalWrite(9, HIGH); //Green ON
delay(1000);
digitalWrite(9, LOW); //Green OFF
digitalWrite(10, HIGH);
//Blue ON
delay(1000);
digitalWrite(10, LOW);
//Blue OFF
delay(1000);
}
--------------------------- Copy Code Above
--------------------------- Copy Code Below
void setup()
{
pinMode(8, OUTPUT); //Red
pinMode(9, OUTPUT); //Green
pinMode(10, OUTPUT);
//Blue
}
void loop()
{
digitalWrite(8, HIGH); //Red
ON
delay(1000);
digitalWrite(8, LOW); //Red
OFF
digitalWrite(9, HIGH); //Green ON
delay(1000);
digitalWrite(9, LOW); //Green OFF
digitalWrite(10, HIGH);
//Blue ON
delay(1000);
digitalWrite(10, LOW);
//Blue OFF
delay(1000);
}
--------------------------- Copy Code Above
No comments:
Post a Comment