-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlink_3_LEDs_Matriz.ino
49 lines (41 loc) · 1.36 KB
/
Blink_3_LEDs_Matriz.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
/*
Blink
The basic Energia example.
Turns on an LED on for one second, then off for one second, repeatedly.
Change the LED define to blink other LEDs.
Hardware Required:
* LaunchPad with an LED
This example code is in the public domain.
*/
// most launchpads have a red LED
#define LEDBLUE BLUE_LED
#define LEDGREEN GREEN_LED
#define LEDRED RED_LED
//see pins_energia.h for more LED definitions
//#define LED GREEN_LED
int timerON = 5; // The higher the number, the slower the timing.
int timerOFF = 10;
int ledPins[] = {
LEDBLUE,LEDGREEN,LEDRED};
int pinCount = 3; // the number of pins (i.e. the length of the array)
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
// the loop routine runs over and over again forever:
void loop() {
// loop from the lowest pin to the highest:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
// turn the pin on:
digitalWrite (ledPins[thisPin],HIGH);
delay(timerON);
// turn the pin off:
digitalWrite (ledPins[thisPin],LOW);
delay(timerOFF);
}
}