C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Controlling Fan With IR Remote Using Arduino Mega 2560
WhatsApp
Sr Karthiga
5y
13.9k
0
2
100
Article
remotefan.zip
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;
//IR receiver pin
Servo servo;
int
val;
//rotation angle
bool
cwRotation, ccwRotation;
//the states of rotation
IRrecv irrecv(RECV_PIN);
decode_results results;
void
setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
// Start the receiver
servo.attach(9);
//servo pin
}
void
loop()
{
if
(irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume();
// Receive the next value
if
(results.value == plus)
{
cwRotation = !cwRotation;
//toggle the rotation value
ccwRotation =
false
;
//no rotation in this direction
}
if
(results.value == minus)
{
ccwRotation = !ccwRotation;
//toggle the rotation value
cwRotation =
false
;
//no rotation in this direction
}
}
if
(cwRotation && (val != 175)) {
val++;
//for colockwise button
}
if
(ccwRotation && (val != 0)) {
val--;
//for counter colockwise button
}
servo.write(val);
delay(20);
//General speed
}
Explanation
In this article I explained about the Contolling the fan by using IR remote.
It can control the speed of ON/OFF and this is can be made by the Arduino Mega 2560.
Arduino
Arduino Mega 2560
Internet of Things
IR Remote
Up Next
Ebook Download
View all
Printing in C# Made Easy
Read by 22.5k people
Download Now!
Learn
View all
Membership not found