User manual
Upload the Code
Below is a version of the IRservo.ino sketch from the IRLib examples folder. It has been modified to
be used with the Adafruit Mini Remote. If you're using a different remote, you will have to collect
information about your codes for various buttons using IRrecvDump and modify the sketch with the
proper protocol name and codes.
#include <IRLib.h>
#include <Servo.h>
// You will have to set these values depending on the protocol
// and remote codes that you are using. These are For the Adafruit
// Mini Remote
#define MY_PROTOCOL NEC
#define RIGHT_ARROW 0xfd50af //Move several clockwise
#define LEFT_ARROW 0xfd10ef //Move servo counterclockwise
#define SELECT_BUTTON 0xfd906f //Center the servo
#define UP_ARROW 0xfda05f //Increased number of degrees servo moves
#define DOWN_ARROW 0xfdb04f //Decrease number of degrees servo moves
#define BUTTON_0 0xfd30cf //Pushing buttons 0-9 moves to fixed positions
#define BUTTON_1 0xfd08f7 // each 20 degrees greater
#define BUTTON_2 0xfd8877
#define BUTTON_3 0xfd48b7
#define BUTTON_4 0xfd28d7
#define BUTTON_5 0xfda857
#define BUTTON_6 0xfd6897
#define BUTTON_7 0xfd18e7
#define BUTTON_8 0xfd9867
#define BUTTON_9 0xfd58a7
IRrecv My_Receiver(11);//Receive on pin 11
IRdecode My_Decoder;
Servo My_Servo; // create servo object to control a servo
int pos; // variable to store the servo position
int Speed; // Number of degrees to move each time a left/right button is pressed
long Previous; // Stores previous code to handle NEC repeat codes
void setup()
{
My_Servo.attach(9); // attaches the servo on pin 9 to the servo object
pos = 90; // start at midpoint 90 degrees
Speed = 3; // servo moves 3 degrees each time left/right is pushed
My_Servo.write(pos); // Set initial position
My_Receiver.enableIRIn(); // Start the receiver
}
void loop()
© Adafruit Industries https://learn.adafruit.com/using-an-infrared-library Page 15 of 23