-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdm.ino
31 lines (29 loc) · 857 Bytes
/
sdm.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
int Led_Red = 10;
int Led_Green = 11;
int Led_Blue = 9;
int val;
void setup () {
// Output pin initialization for the LEDs
pinMode (Led_Red, OUTPUT);
pinMode (Led_Green, OUTPUT);
pinMode (Led_Blue, OUTPUT);
}
void loop () {
// In this for loop, the two LEDs will get different PWM-Values.
// Via mixing the brightness of the different LEDs, you will get different colors.
for (val = 255; val> 0; val--)
{
analogWrite (Led_Red, val);
analogWrite (Led_Blue, 255-val);
analogWrite (Led_Green, 128-val);
delay (15);
}
// You will go backwards through the color range in this second loop.
for (val = 0; val <255; val++)
{
analogWrite (Led_Red, val);
analogWrite (Led_Blue, 255-val);
analogWrite (Led_Green, 128-val);
delay (15);
}
}