7/23/22, 9:39 PM
Seeeduino XIAO Expansion board - Seeed Wiki
https://wiki.seeedstudio.com/Seeeduino-XIAO-Expansion-Board/
33/66
Studio/Seeed_Arduino_IRSendRev]
[https://wiki.seeedstudio.com/How_to_install_Arduino_Library/]
Step 4
. Copy the code stick on the Aruino IDE then upload it.
Step 5
. Place the Fan in the safety position, try to press the button
make sure it can work safely.
Code
1
#include <IRremote.h>
2
#include <Servo.h>
3
4
Servo myservo;
// create servo object to control a servo
5
int
RECV_PIN =
7
;
// set pin 2 as IR control
6
7
IRrecv
irrecv
(RECV_PIN);
8
9
decode_results results;
10
11
int
pos =
90
;
// variable to store the servo position
12
int
fanPin =
0
;
// set D6 as control switch
13
int
fanState = LOW;
14
int
IO =
0
;
15
16
void
setup
()
17
{
18
Serial.begin(
9600
);
19
Serial.println(
"Enabling IRin"
);
// remind enabling IR
20
irrecv.enableIRIn();
// Start the receiver
21
Serial.println(
"Enabled IRin"
);
22
myservo.attach(
5
);
// attaches the servo on pin 2 to t
23
pinMode(fanPin, OUTPUT);
24
25
}
26