-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTemplate.ino
52 lines (38 loc) · 1.13 KB
/
Template.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
Demonstrates Common-Cathode LED
Demonstrates the different states of a Common-Cathode LED by connecting
the cathode to ground and giving a signal (applying current) to the two signal pins.
Board:
* Arduino UNO
The circuit:
* 330 Ohm resistor
* KY-029 - Common-Cathode RED&GREEN LED / Yin Yi 2-color LED 3mm
* 3 x MALE-MALE Jumper Wires
Created By
Christer Nordbø (@CNordbo)
https://github.com/Cnordbo/arduino-sensor-docs
*/
void setup() {
// Signal pin for the GREEN LED
pinMode(A0, OUTPUT);
// Signal pin for RED LED
pinMode(A1, OUTPUT);
}
void loop() {
// Turn GREEN LED "ON" and RED LED "OFF"
digitalWrite(A0, HIGH);
digitalWrite(A1, LOW);
// Wait 1 second before moving on
delay(1000);
// Turn GREEN LED "OFF" and RED LED "ON"
digitalWrite(A0, LOW);
digitalWrite(A1, HIGH);
// Wait 1 second before moving on
delay(1000);
// Turn GREEN LED "ON" and RED LED "ON"
// This will blend the colors, making the end result "Orange"
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
// Wait 1 second before ending the loop, and starting from top again.
delay(1000);
}