forked from hexbright/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hexbright_demo_dazzle.ino
executable file
·49 lines (41 loc) · 1.04 KB
/
hexbright_demo_dazzle.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
/*
Hexbright demo firmware: Dazzle
Andrew Magill 9/2012
Dazzler flashes while the button is down.
*/
// Pin assignments
#define DPIN_RLED_SW 2
#define DPIN_GLED 5
#define DPIN_PWR 8
#define DPIN_DRV_MODE 9
#define DPIN_DRV_EN 10
void setup()
{
// If we leave the regulator's enable pin as high-impedance,
// the regulator will power down the board about a half
// second after release of the button.
pinMode(DPIN_PWR, INPUT);
digitalWrite(DPIN_PWR, LOW);
// Initialize GPIO
pinMode(DPIN_RLED_SW, INPUT);
pinMode(DPIN_GLED, OUTPUT);
pinMode(DPIN_DRV_MODE, OUTPUT);
pinMode(DPIN_DRV_EN, OUTPUT);
digitalWrite(DPIN_DRV_MODE, HIGH);
digitalWrite(DPIN_DRV_EN, LOW);
digitalWrite(DPIN_GLED, HIGH);
}
void loop()
{
static unsigned long lastTime;
if (digitalRead(DPIN_RLED_SW))
{
if (millis() - lastTime > 10)
{
digitalWrite(DPIN_DRV_EN, random(4)<1);
lastTime = millis();
}
}
else
digitalWrite(DPIN_DRV_EN, LOW);
}