With this simple Arduino project you can feed your pet using a remote control. All you need is an Arduino Uno board (or similar), a plastic bottle, a servo motor (doesn't have to be very powerful), a TV remote, IR receiver (TS0P1738) and a small piece of cardboard.
Let's get started!
Installing the IR Library:The very first thing that we need to do associating with arduino is to download the IR library.
Download IR library from below link and install it: https://github.com/z3t0/Arduino-IRremote
If you don't know how to install a library follow below link: https://www.arduino.cc/en/guide/libraries
Decoding IR Signals:First you need to connect the parts as per the given circuit diagram:
You can checkout Pin out of TSOP1738 below:
Use following code to decode IR remote:
/*
The IR sensor's pins are attached to Arduino as so:
Pin 1 to Vout (pin 11 on Arduino)
Pin 2 to GND
Pin 3 to Vcc (+5v from Arduino)
*/
#include <IRremote.h>
int IRpin = 11;
IRrecv irrecv(IRpin);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, DEC); // Print the Serial 'results.value'
irrecv.resume(); // Receive the next value
}
}
- Open Arduino IDE and Upload code
- Open Serial Monitor
- Aim your remote at the sensor and press each button
- You can see different numbers for each button
Consider any two buttons, and note down decoded values.In my case I have chosen Power button and Mode button.
I got the following values:
- Power button=33441975
- Mode button =33446055
We will be using this two values to control rotation of servo motor.you need to add this two values in the program which is given on next step:
Let's set-up the final hardware!
The Final Circuit!- Connect the servo's signal pin to pin#9 on the arduino
- connect the servo's VCC and GND pins to 5V VCC and GND on the arduino
- The servo will be glued to one end of the plastic bottle, and rotate a piece of cardboard small enough to close the opening of the bottle so that the food is blocked.
- If all the hardware set-up is connected properly, you can simply compile and upload the following sketch to the board.
#include <IRremote.h>
#include <Servo.h>
int IRpin = 11; // pin for the IR sensor
IRrecv irrecv(IRpin);
decode_results results;
Servo myservo;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume(); // Receive the next value
}
if (results.value == 33441975) // change according to your IR remote button number
{
myservo.write(0);
delay(15);
}
if (results.value == 33446055) // change according to your IR remote button number
{
myservo.write(30);
delay(15);
}
}
Now you can control your opening of pet feeder dispenser with remote control by this simple project. :-)
Happy making!
Comments