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
|Left Joystick Vertical Axis
|Right Joystick Horizontal Axis
|Right Joystick Vertical Axis
|Left Face Button
|Right Face Button
|Left Trigger Button
|Right Trigger Button
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!