forked from TTKLabs/TTKIOT-SB-DM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.cpp
50 lines (46 loc) · 854 Bytes
/
button.cpp
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
#include "button.h"
#include "leds.h"
int loopCounter = 0;
bool buttonPressed = false;
void buttonSetup()
{
pinMode(TTKIOT_BUTTON_PIN, INPUT);
attachInterrupt(TTKIOT_BUTTON_PIN, buttonPress, CHANGE);
}
void buttonPress()
{
buttonPressed = true;
}
void myAlarm()
{
if (loopCounter > 100)
{
police2(255);
}
else
{
police(255);
}
}
void buttonRun()
{
if (buttonPressed)
{
myAlarm();
}
buttonPressed = false;
if (loopCounter == 50)
{
circleBack(random(1, 255), random(1, 255), random(1, 255));
}
if (loopCounter == 100)
{
circle(random(1, 255), random(1, 255), random(1, 255));
}
if (loopCounter == 150)
{
circleBack(random(1, 255), random(1, 255), random(1, 255));
loopCounter = 0;
}
loopCounter++;
}