Challenge Name:
Flashy lights
Author:
Joshua Mac
Credit:
Aron Graca
Difficulty Level:
3
Time to Complete:
5mins
Challenge Description:
Make an RGB blink blue and red fast.
Hint:
None
Answer:
const int RED_LED_PIN = 9;
const int BLUE_LED_PIN = 11;
int redIntensity = 0;
int blueIntensity = 0;
const int DISPLAY_TIME = 10;
void setup()
{
}
void loop()
{
for (blueIntensity = 0; blueIntensity <= 255; blueIntensity+=5)
{
redIntensity = 255-blueIntensity;
analogWrite(BLUE_LED_PIN, blueIntensity);
analogWrite(RED_LED_PIN, redIntensity);
delay(DISPLAY_TIME);
}
for (redIntensity = 0; redIntensity <= 255; redIntensity+=5)
{
blueIntensity = 255-redIntensity;
analogWrite(RED_LED_PIN, redIntensity);
analogWrite(BLUE_LED_PIN, blueIntensity);
delay(DISPLAY_TIME);
}
}
No comments:
Post a Comment