-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLEDControl.cpp
More file actions
49 lines (40 loc) · 1.29 KB
/
Copy pathLEDControl.cpp
File metadata and controls
49 lines (40 loc) · 1.29 KB
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
//LEDControl(x,2), lcddisplay will constant
//LEDControl(x,1), delaying 0.75s
//LEDID: -1=green(avaliable), 0=blue(temporarily out), 1=red(occupied)
//action: 2=on, 1=flash, 0=off
#define RLED 5
#define GLED 4
#define BLED 3
#include "LEDControl.h"
#include "Arduino.h"
void LEDControl(int LEDID, int action) {
pinMode(RLED, OUTPUT);
pinMode(GLED, OUTPUT);
pinMode(BLED, OUTPUT);
if ( LEDID == -1 && action == 2 ) digitalWrite(GLED, HIGH);
if ( LEDID == 0 && action == 2 ) digitalWrite(BLED, HIGH);
if ( LEDID == 1 && action == 2 ) digitalWrite(RLED, HIGH);
if ( LEDID == -1 && action == 0 ) digitalWrite(GLED, LOW);
if ( LEDID == 0 && action == 0 ) digitalWrite(BLED, LOW);
if ( LEDID == 1 && action == 0 ) digitalWrite(RLED, LOW);
//-----flashing itself has the function of delaying .75 seconds.-----//
// if you want flash twice, call it twice.
if ( LEDID == -1 && action == 1 ) { // Green flash
digitalWrite(GLED, HIGH);
delay(375);
digitalWrite(GLED, LOW);
delay(375);
}
if ( LEDID == 0 && action == 1 ) { // blue flash
digitalWrite(BLED, HIGH);
delay(375);
digitalWrite(BLED, LOW);
delay(375);
}
if ( LEDID == 1 && action == 1 ) { // red flash
digitalWrite(RLED, HIGH);
delay(375);
digitalWrite(RLED, LOW);
delay(375);
}
}