-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwiretx.ino
85 lines (79 loc) · 1.53 KB
/
wiretx.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
void transmit() {
if(sensorid != 300){
for (int i=0;i<2;i++){
if(i==1){
Wire.beginTransmission(9); // transmit to device #9
Wire.write(sensorid); // sends x
Wire.endTransmission(); // stop transmitting
}
}
}}
void blinkred()
{
now = millis();
if(now - prev >= period)
{
boolean state = digitalRead(red);
digitalWrite(red, !state);
prev = now;
}
}
void blinkgreen()
{
nowg = millis();
if(nowg - prevg >= periodg)
{
boolean stateg = digitalRead(green);
digitalWrite(green, !stateg);
prevg = nowg;
}
}
void buzz(){
digitalWrite(buzzer, HIGH);
delay(200);
digitalWrite(buzzer,LOW);
delay(10);
}
void buzz2(){
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
delay(100);
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
delay(100);
}
void buzz3(){
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
delay(50);
}
void beepAfter1minute(){
minNow = millis();
digitalWrite(buzzer, LOW);
if (minNow - minPrev >= minT){
minState = !minState;
minPrev = minNow;
}
if (minState == !minState){
for (size_t i = 0; i < 4; i++)
{
beepNow = millis();
if (beepNow - beepPrev >= beepT)
{
digitalWrite(buzzer, !(digitalRead(buzzer)));
beepPrev = beepNow;
}
}
}
}