Introduction: Making Your Own Infrared Controller With Arduino
Have a robot that would benefit from a customized controller? Tiny remotes not doing your project justice? Maybe your project would benefit from the use of joysticks instead of itty bitty buttons? In this instructable, we will be making our own Infrared Controller with two joysticks, two face buttons, and two trigger buttons that you can use to control just about anything with an infrared receiver! Let's get going!
Step 1: Project Parts List
You can use any number of parts to make this happen, but we're going to set out to make a controller with 2 joysticks, 2 face buttons, and 2 trigger buttons. To do this, you'll need:
- 1 x Geekduino or other Arduino UNO equivalent
- 1 x RobotGeek Sensor Shield
- 1 x Duino Mount
- 1 x Small Workbench
- 1 x 4 AA Battery Pack
- 2 x RobotGeek Joystick
- 4 x RobotGeek Pushbutton
- 1 x RobotGeek IR Transmitter
- 1 x Experimenter's Nut and Bolt Pack
Now, obviously this controller needs a device to pair up with. If you're building a robot with arduino, we suggest using something like the RobotGeek IR Receiver to pick up signal from the controller.
You can pair this controller up with just about any IR controlled device, so long as you have the original remote to copy the signal codes from!
Step 2: Assembly / Wiring
Here is an example layout, putting the two joysticks, two buttons, and IR Transmitter on the top of the workbench. On the bottom, we mounted the Geekduino & Sensor Shield, battery holder, and two trigger buttons. You can lay it out however you like, this is just a recommendation.
Follow the diagram and use this table to wire up your controller.
Device | Sensor Shield Port |
---|---|
Left Joystick Horizontal Axis RobotGeek Joystick 1 | AIO-0 |
Left Joystick Vertical Axis RobotGeek Joystick 1 | AIO-1 |
Right Joystick Horizontal Axis RobotGeek Joystick 2 | AIO-2 |
Right Joystick Vertical Axis RobotGeek Joystick 2 | AIO-3 |
Left Face Button RobotGeek Pushbutton 1 | DIO-2 |
Right Face Button RobotGeek Pushbutton 2 | DIO-4 |
Left Trigger Button RobotGeek Pushbutton 3 | DIO-7 |
Right Trigger Button RobotGeek Pushbutton 4 | DIO-8 |
IR Transmitter RobotGeek IR Transmitter | DIO-3 |
Step 3: Programming the Controller
The IRLib Library and Custom IR Controller Sketch are included in the RobotGeek Libraries and Tools. Download and extract it to your Arduino folder.
To get it up and running, all you need to do is open:
File → Sketchbook → RobotGeekSketches → Demos → IR → IRcustomController
and upload it to your board.
We could move on, but let's take a quick look at the code to get an idea of what we're working with.
const int Set_Protocol = NEC; //Left Joystick const unsigned long L_JOY_RIGHT_ARROW = 0xFFC23D; const unsigned long L_JOY_LEFT_ARROW = 0xFF22DD; const unsigned long L_JOY_UP_ARROW = 0xFF629D; const unsigned long L_JOY_DOWN_ARROW = 0xFFA857; //Right Joystick const unsigned long R_JOY_RIGHT_ARROW = 0xFD50AF; const unsigned long R_JOY_LEFT_ARROW = 0xFD10EF; const unsigned long R_JOY_UP_ARROW = 0xFDA05F; const unsigned long R_JOY_DOWN_ARROW = 0xFDB04F; //Buttons const unsigned long L_FACE_BUTTON = 0xFF02FD; const unsigned long R_FACE_BUTTON = 0xFF6897; const unsigned long L_TRIGGER_BUTTON = 0xFFB04F; const unsigned long R_TRIGGER_BUTTON = 0xFF52AD;
So here, we're defining the protocol we'll be using to send the command, then setting a list of unsigned long constants. The 6 characters after the 0x
are what we're sending. These specific values were borrowed from two separate mini IR remotes, but can be different values depending on what you'd like to control. If you want to make a replacement controller for your device, you can learn about grabbing IR codes from another remote in this instructable.
Step 4: Programming Your Device
You can see some examples of code that uses an IR receiver in the Turret and Rover with IR Remote Instructables. Taking a look at this code, you can see that the IRLib library decodes the signal based on the selected remote in the remotes.h file, and simple if/else if statements are used to handle the specifics of the command. This instructable can teach you a little bit more about using an IR Receiver.
Step 5: You're All Set!
What will you control with your new infrared controller? Can you think of other layouts that might work better for different devices? What about adding a light so you know when you're sending data, or a buzzer to let you know when the remote is on and hasn't been used in a while? There are so many things to do, we'd love to hear what you come up with!
9 Comments
5 years ago
I dont have this libary. how can I make it to libary?
Reply 5 years ago
I have got the library , its name is "rc-switch-master".
Now can you tell the code please.
6 years ago
Great tutorial, would it be possivle to use radio rather than IR?
Reply 6 years ago
It would need completely different coding and libraries to work with a radio transmitter, but it's absolutely possible.
Reply 5 years ago
Can somebody tell the code for using rf instead of ir ?
PLEASE !!!!!!!!
Reply 5 years ago
Is 1rf transmitter better or multiple ir transmitter is better?
6 years ago
Would I be able to use one controller for multiple objects (robot, car, motorcycle) or would I have to make one for each? I have alot of receivers but only 1 transmitter right now ( and very little space)
Reply 6 years ago
One controller could absolutely control multiple objects, so long as you have good line of sight with all of them. Just set different signal codes for each of them!
Reply 6 years ago
Awesome! I would rather have one IR controller than 4 or 5. I'll be making one right after I make a universal remote to get rid of the 6 or 20 I have laying around the house, I cant keep track of these things anymore...