Introduction
- In this article you will learn about how to control Fan with IR Remote using Arduino Mega 2560.
- We can control the fan by using the remote in our place if we want to control the fan by the remote.
Parts Of Lists
- Arduino mega 2560
- IR Remote
- Servo Motor
- Bread Board
- Hook Up wires
Connection
Step 1
Connect the IR Remote to the Arduino Mega 2560
- Connect the IR Sensor to the arduino board Vin -3pin,
- Connect the IR Sensor to the arduino board Gnd - Gnd.
- Connect the IR Sensor to the arduino board Vcc - 5v.
Step 2
Connect the ServoMotor To the Arduino Mega 2560
- Connect the Vcc of the servo Motor to the 5v of the ArduinoMega2560.
- Connect the gnd of the bluetooth to the Gnd of the ArduinoMega2560.
- Connect the Vin of the bluetooth to the 09 of the ArduinoMega2560.
Programming
- #include <IRremote.h> //must copy IRremote library to arduino libraries
- #include <Servo.h>
- #define plus 0xA3C8EDDB //clockwise rotation button
- #define minus 0xF076C13B //counter clockwise rotation button
-
- int RECV_PIN = 3;
- Servo servo;
- int val;
- bool cwRotation, ccwRotation;
-
- IRrecv irrecv(RECV_PIN);
-
- decode_results results;
-
- void setup()
- {
- Serial.begin(9600);
- irrecv.enableIRIn();
- servo.attach(9);
- }
-
- void loop()
- {
- if (irrecv.decode(&results)) {
- Serial.println(results.value, HEX);
- irrecv.resume();
-
- if (results.value == plus)
- {
- cwRotation = !cwRotation;
- ccwRotation = false;
- }
-
- if (results.value == minus)
- {
- ccwRotation = !ccwRotation;
- cwRotation = false;
- }
- }
- if (cwRotation && (val != 175)) {
- val++;
- }
- if (ccwRotation && (val != 0)) {
- val--;
- }
- servo.write(val);
- delay(20);
- }
Explanation
- In this article I explained about the Contolling the fan by using IR remote.
- It can contol the speed of ON/OFF and this is can be made by the Arduino Mega 2560.