7/23/22, 9:39 PM
Seeeduino XIAO Expansion board - Seeed Wiki
https://wiki.seeedstudio.com/Seeeduino-XIAO-Expansion-Board/
34/66
27
void
loop
() {
28
if
(irrecv.decode(&results)) {
//checking IR signal
29
if
(results.
value
==
2155829415
) {
// Power off/on
30
IO++;
31
if
(IO %
2
==
0
) {
32
fanState = HIGH;
33
digitalWrite(fanPin, fanState);
34
delay(
100
);
35
}
36
else
{
37
fanState = LOW;
38
digitalWrite(fanPin, fanState);
39
delay(
100
);
40
}
41
}
42
43
if
(results.
value
==
2155821255
) {
// fan swing t
44
for
(pos; pos <=
89
; pos +=
1
) {
// goes from 0 deg
45
// in steps of 1 degree
46
myservo.write(pos);
// tell servo to
47
48
delay(
40
);
// waits 15ms fo
49
if
(irrecv.decode(&results)) {
50
irrecv.resume();
51
if
(results.
value
==
2155870215
)
52
break
;
53
}
54
}
55
}
56
57
if
(results.
value
==
2155870215
) {
// fan swing t
58
for
(pos; pos >=
1
; pos -=
1
) {
// goes from 90 deg
59
myservo.write(pos);
// tell servo to
60
delay(
40
);
// waits 15ms fo
61
62
if
(irrecv.decode(&results)) {
63
irrecv.resume();
64
if
(results.
value
==
2155821255
)
65
break
;
66
}
67
}