Last week, I posted a demo on building impBot, a simple pan/tilt servo "robot" controlled via the internet with the electric imp. At the time, all I had for controlling said robot was a potentiometer in a box, which made the overall usefulness a little underwhelming. This week, I've got a demo on how to build a better way to control the impBot (or just about anything else, for that matter) by creating an internet-connected joystick using one of Sparkfun's thumb joysticks

These thumb joysticks are wonderfully simple, and have a select button along with the X and Y axis outputs; they're just like the analog controls on your playstation controller (quite possibly the exact same part, actually). Fully interfacing to one with the imp takes just three signal wires (X, Y, Button), 3.3V from the Electric Imp Breakout Board's regulator, and ground: 5 wires. The hardest part about the whole thing is just getting the whole apparatus packed up attractively in a box. 

Once you've got this project all set up, you've got an internet-connected X-Y control with a select button - twice as powerful as the controlBox + a button!

Step 1: What You'll Need

Most of the work here is mechanical! Here's the parts list:
  1. Electric Imp
  2. Electric Imp breakout board
  3. Enclosure: I used a Hammond 1593PBK hand-held instrument enclosure with battery holder
  4. A bit of perfboard. Plated is easier to solder. 
  5. A SPDT switch (for power)
  6. Some 4-40 screws (4 of them, actually)
  7. Some foam tape
  8. A bit of heat shrink tubing
And here's the tools you'll need:
  1. A drill. You'll need a few important bits:
    1. A center punch and a small hammer for marking and starting holes
    2. A 1/8" drill for starting holes and drilling mounting holes in your perfboard
    3. A drill sized for your SPDT switch. Mine was 3/16"
    4. A hole cutter, 1" , to make a hole for the joystick
  2. A 4-40 tap and tap handle for threading the mounting holes for the joystick.
  3. A dremel or similar for cutting a slot for the imp and cutting down your perfboard
  4. A respirator or mask - don't cut FR4 (the material your perfboard is made of) without one! If you're not cutting FR4, you won't need this.
  5. Soldering iron and solder
  6. A heat gun for shrinking heat shrink. A hair dryer will do in a pinch
  7. Angle cutters and wire strippers
  8. Adjustable wrench
  9. Philips-head screwdriver
To interact with the imp, you need a few important pieces:
  1. A smartphone running the free electric imp app to "blink up" your imp onto your network
  2. A computer to access the electric imp planner (http://plan.electricimp.com)
  3. A free electric imp developer account for planner access (just sign up and you're good to go)
When you've got your requisite parts, take a look at the schematic and get a quick idea of what we're going to do. We'll start by putting some leads on your electric imp breakout board.

Step 2: Getting Started: Preparing Your Breakout Board

At this step, there are a few things we're going to do:
  1. Remove tall components from the breakout board, if necessary
  2. Add three leads for the X, Y, and Button inputs to the electric imp
  3. Add leads for power and ground to the joystick
  4. Connect the power select switch to the breakout board
  5. Connect the battery pack to the breakout board
Using the enclosure that I chose, there is not room for the electric imp breakout board, joystick breakout board, and battery pack to all sit side-by-side, so I had to do a little bit of creative packing. More specifically, I tucked the electric imp breakout board underneath the battery pack. This worked like a charm; everything fits, the imp has no trouble connecting, and you've got room for all the pieces. To make this work, though, all the really tall components have to come off of the electric imp breakout board: the USB header and the male pin headers for the power select jumper (if populated) are the two offenders. 

If you're using the sparkfun breakout, no male pin headers for the power select jumper are populated, but you still have a USB header that's going to get in the way. Let's remove that first. To get it off of there, the best thing to do is heat the whole area, then gently push the connector off the board, taking care not to lift the pads in case you'd like to put it back on there. Here's what I did:
  1. (optional) Use some solderwick and a soldering iron to get most of the solder off of the pads. There are four big mechanical pads at each of the four corners of the connector, and five small pads along the back of the connector
  2. Break out the heat gun and turn it up. If you've got a preheater that you can place the board on top of, this will help too. Heat the area evenly with the heat gun until the solder on all of the pads flows - you'll see it become shiny.
  3. Keeping the heat on the part, gently nudge the connector off the board with tweezers, then pull the heat gun away. 
If you have a breakout board from Electric Imp, or you've populated the power select pads with headers yourself, you'll need to remove them, too. I did. Here's how I did it:
  1. Use angle cutters to cut the header pins off right at the board. 
  2. One by one, heat the pads with the soldering iron. With the iron still on the pad, use a solder sucker to remove solder (and the remaining bit of header pin) from the joint.
  3. If the solder sucker can't get the hole clear, you can use tweezers to pull the bit of remaining pin out of the hole while heating it with the soldering iron.
Ok! The board is ready. Let's go ahead and put leads on for the joystick. I'll follow the wire color conventions as shown on the breadboard diagram in the previous step (not as shown in the pictures). 
  1. Cut 3 pieces of wire, 4" to 6". You can use any three colors, but I recommend not using red or black. Following the color convention used in the breadboard diagram:
    1. Blue wire for the Y axis
    2. Yellow wire for the X axis
    3. Purple wire for the button
  2. Strip about 1/8" of insulation off of each end of each wire. 
  3. Solder the wires to the appropriate pin on your breakout board (follow the labels silkscreened on the breakout board):
    1. Blue to pin1
    2. Yellow to pin2
    3. Purple to pin5
  4. To solder them down easily, I recommend you place all three wires through the holes with the board upright, tape them in place with a bit of kapton tape, then flip the board over, solder them in, and trim the excess with angle cutters.
  5. Using the same procedure, solder a 4" to 6" piece of red wire to the 3V3 terminal on your breakout board, and a 4" to 6" piece of black wire to the GND terminal (either one is fine, but things will look cleaner if you use the one right next to the 3V3 terminal)
Alright, now let's add the power switch. Again, using the color convention on the breadboard diagram, not in the pictures:
  1. Cut three pieces of wire, 4" to 6", red, yellow, and purple, and strip 1/4 of insulation off of each end
  2. Solder each to one of the three power select holes on your breakout board, just like you did with the leads for the joystick. Trim the excess off the back of the board when you're done.
    1. the red wire goes to the center terminal
    2. Purple wire to the terminal labeled "BAT" (Battery)
    3. Yellow wire to the terminal labeled "USB" (USB power supply)
  3. Cut three 1/2" pieces of heat shrink and slide them over the wires, down toward the breakout board.
  4. Tape your switch down to something to hold it in place, and solder the three leads to it. Red wire goes to the center pin on the switch, purple and yellow to the sides (either side is fine). To solder to the switch:
    1. Heat the pin you're trying to solder to
    2. Flow a little solder onto the pin on the switch. 
    3. Put down the solder and pick up the wire you're going to connect to the switch terminal. Tweezers can be helpful for this as they'll keep you from burning your fingers.
    4. Heat the pin on the switch again until the solder flows and slip the wire through the hole in the center of the lug on the switch
    5. Remove the heat, let the solder cool before letting go of the wire, and trim the excess
  5. With the switch all soldered, slide the heat shrink back up and over the solder lugs on the switch, and use a heat gun to shrink it into place. 
Ok, last part: connect the battery pack to the breakout board:
  1. Tape your breakout board to something to hold it in place
  2. Heat the P+ pad and flow a bead of solder onto it. Put down the solder and pick up the red wire on the battery pack.
  3. Heat the P+ pad back up until the solder flows, holding the stripped end of the red battery pack wire against it. 
  4. Remove the heat and hold the wire in place until the solder cools
  5. Repeat with the P- pad and the black wire on the battery pack. 
Ok! All wired up on the breakout board side. Let's do a little mechanical work, then connect up the joystick. 

Step 3: Prep the Case to Mount the Joystick

Alright, two big parts to this step: cutting the hole for the joystick in the top of the case, and tapping the holes for the mounting hardware for the joystick in the bottom of the case. While we're at it, we'll drill a hole for the power switch. Let's tap the holes first.

IMPORTANT: WE NEED TO TAP THE HOLES IN THE *BOTTOM* HALF OF THE CASE. That is, the half with the battery door. The four holes we're tapping are in the mounting bosses on the inside of the bottom half of the case. They form a square 1.1" by 1.1" and are in the half opposite the battery door. 
  1. Break out the 4-40 tap and mount it in the tap handle. 
  2. Carefully tap the four mounting holes in the bottom of the case with the tap.
    1. Holding the tap very, very steady and applying firm downward pressure on the tap handle, place the tap in the center of the hole in the boss you're going to tap.
    2. I recommend holding the tap still and actually turning the case itself on the table. It's just easier to keep the tap vertical this way. 
    3. The tap will draw itself into the hole as it cuts the threads
    4. Tap until you hit the bottom of the boss. It's maybe 1/4" of thread. 
    5. Repeat for each of the four holes
Great, now we've got a place to mount the joystick. Just need to make a clearance hole for it. 

IMPORTANT: WE'RE CUTTING THE CLEARANCE HOLE IN THE *TOP* HALF OF THE CASE. That is, the half that *does not* have a battery door in it. We'll be cutting the hole in the end OPPOSITE the end with the place where the imp and battery pack will sit. 

Clamp the top half of the case in a vise and measure out from the edges of the flat surface. You want to center the hole between the left and right sides, about 1.2" from either edge of the flat top of the case. The hole will be about 1" from the end of the case - that is, from the end OPPOSITE the end where the battery pack will sit. 
  1. Measure and mark the hole position
  2. Centerpunch the hole you're going to drill
  3. Drill an 1/8" starter hole. 
  4. Use the 1" hole cutter to cut... a 1" hole! 
  5. Clean up the edges of the hole with sandpaper or an x-acto knife
Last but not least, we need to drill a 3/16" hole in the end plate that goes across the top of the case. Center the hole between the long sides of the plate, about 1" from the end of the plate. Centerpunch the hole, then go ahead and just drill with the 3/16" drill (no need to pre-drill the hole with a smaller bit, as the hole is small).

Ok, the enclosure is ready for the joystick! We need to install the imp breakout board next, so check out the next step.

Step 4: Mount the Breakout Board in Place

Ok, short step. We need to set the imp breakout board in place, cut a slot through the enclosure for the imp, and add the battery pack.

IMPORTANT: WE'RE MOUNTING THE IMP AND CUTTING THE SLOT IN THE *TOP* HALF OF THE CASE. That is, the half with no battery door. The imp sits right under where the batteries will go.

First, we need to mark out the slot for the imp and cut the slot with the dremel. I recommend using the cutoff wheel tool on the dremel for this.
  1. Put a 1" long piece of foam tape on the bottom of the enclosure on the battery-pack side. Leave the backing on the top side (don't expose the adhesive).
  2. Set the breakout board on top of the tape and slide the imp socket up to the edge of the case. Mark out the outline of the imp slot on the inside wall of the case. I used an x-acto knife for this.
  3. Remove the imp breakout board from the case. Mount the case in a vise, if you've got one. If not, secure it in place with a healthy dose of tape or similar.
  4. Cut out the marked area from the inside of the case with the dremel. Cutting from the inside keeps the outside looking clean. Clean up the excess with the x-acto knife when you're done. 
  5. Peel off the backing on the foam tape and mount the breakout board in place.
Alright! Now for the battery pack. 
  1. Cut three short pieces of foam tape, each about 1/4" in length. Place two on the inside wall of the case, above the imp breakout board along its long side. Place the third on the inside wall of the case, centered above the pin terminals on the end of the breakout board. 
  2. Peel the backing off the tape and set the battery pack on top of the imp breakout board, not touching the tape.
  3. Slide the battery pack into the corner of the case so that the two sides facing the tape contact the tape at the same time. This is a little tricky, take it slow and careful.
And that's it! Time to set up a breakout board for the joystick. 

Step 5: Mount the Joystick on Some Perfboard (making a Joystick Breakout)

If you bought the sparkfun (or other) joystick on a breakout board already, this step is a bit null and void, but if you're following my design to the letter, it's time to mount the joystick on some perfboard so we can solder to it and hold it down on the bottom of the case. 

First, let's prep the perfboard:
  1. Mark out the outline of the board you'll need, 1.5" by 1.5". It's 15 rows by 15 rows if you're using standard .1" pitch perfboard. See the images for a mechanical drawing. 
  2. Drill holes for the four mounting points. Use a 1/8" drill. You can use existing holes in the perfboard as your starter holes, which makes things really easy.
    1. The holes are in a square pattern, 1.1" by 1.1" (11 rows apart)
    2. IMPORTANT: WEAR A RESPIRATOR WHEN CUTTING FR4. That's fiberglass and other nasty stuff! You don't want that in your lungs!
  3. Drill or dremel holes for the four mechanical mounting points on the joystick. They form a square, .6" by .6"; center the pattern on the board. Again, you can use the existing holes as starter holes. The 1/8" drill may be a bit large for this if you're going to drill them out, so use something smaller if you've got it. 
  4. You can dremel or saw the perfboard to the outline you need. Respirator required!
  5. Pop the joystick onto the board! The pin pattern isn't a *perfect* fit, so watch the pins and guide them carefully into the board with tweezers if necessary.
  6. Flip the whole thing over and put a big blob of solder on the bottom of each of the mechanical pins in the corners to hold it in place. 
Ok, time to wire the board up in relation to itself. 
  1. Orient the joystick as it will be oriented in the box. I recommend that the X-axis potentiometer be on the bottom, placing the Y-axis potentiometer on the right side. 
  2. Cut and strip a short (1" or so) piece of red wire. Push the stripped ends through the perfboard from the top side, leaving the exposed wire on the bottom side. The goal here is to connect the rightmost pins on the two potentiometers (we'll then wire 3.3V in from the breakout board to these two pins). Solder into place as follows:
    1. Push the wire through a hole adjacent to the pin you want to solder to
    2. Flip the board over
    3. Fold the exposed wire onto the pin you're trying to solder to
    4. Heat the pin and wire together with the soldering iron and flow some solder onto the joint
    5. Trim excess wire
  3. Repeat step 2 with a piece of black wire, connecting the leftmost pins on the two potentiometers
  4. Using the same procedure as with steps 2 and 3, connect the leftmost pin of the x-axis potentiometer to the bottom-right pin on the button (if you're looking at the joystick from the top).
Ok! Now you can wire the breakout board to the joystick. 
  1. Connect pin1 on the breakout board (blue wire!) to the center pin of the Y-axis pot
  2. Connect pin2 on the breakout board (yellow wire!) to the center pin on the X-axis pot
  3. Connect pin3 on the breakout board (purple wire!) to the bottom-left pin on the button (again, looking at the joystick from the top)
  4. Connect GND on the breakout board (black wire!) to any of the pins you've wired together with black jumper wires on the joystick (leftmost pin on either pot, bottom-right pin on the button)
  5. Connect 3.3V on the breakout board (red wire!) to the rightmost pin on either potentiometer. 
With the joystick all connected, you can actually put some batteries in, skip to the last step, and test your joystick to make sure it'll work before finishing up your mechanical assembly. In fact, I recommend it! Once you're satisfied you've got it all wired up right, head to the next step to finish up the assembly. 

Step 6: Assemble!

Ok, all the pieces are ready now. Time to put it together. 
  1. Mount the joystick to the bottom half of the case (where you tapped the holes).
    1. Set it in place, orienting it as you did when you wired up the board (x-axis pot on the bottom, y-axis pot on the right side)
    2. Screw the four 4-40 screws into the holes you tapped
  2. Tuck the wires out of the way. You can secure them with tape if you need to.
  3. Install the power switch in the end plate. Remove the nut from the threaded portion of the switch (if installed), feed the switch through the 3/16" hole you drilled, and secure it in place with the nut. Tighten gently with an adjustable wrench. 
  4. Slide the plate into place with the slots at the end of the case
  5. Math the two halves of the case up and secure them together with the four flat-head screws that came with the case
  6. Install two UltraFire lithium-ion batteries in the battery case. Note that these are 3.6V each, not the typical 1.5V you get with a AA alkaline battery. This means the supply voltage to the breakout board is 7.2V, which means the on-board regulator gets to do its job and make 3.3V for the imp.
  7. Slide the battery door into place. 
  8. Install an imp
Ok! Time to blink up and set the firmware. 

Step 7: Blinkup and Planner

Time to set up the software and get your joystick connected to the internet. First, we need to get your imp connected to your network and visible in planner.
  1. Open the electric imp app on your smartphone and sign in to your account. If you don't have one yet, sign up at http://plan.electricimp.com.
  2. Add your wireless network to the electric imp app by providing the SSID and password.
  3. Hold the screen of your phone up to the end of the (powered on) electric imp and hit "send blinkup" in the electric imp app.
    1. The screen of your phone will flash white and black for a few seconds. What's happening here is that the SSID and password for your network are being sent to the imp so that it knows how to connect to the internet.
    2. The imp will blink green once after it successfully receives this information. If it blinks red quickly three times immediately after the blinkup is sent, it didn't get the info and you need to try again. Check out forums.electricimp.com for more help if you have trouble.
    3. The imp will then perform DNS with your router to get online. It will blink red as it looks for the network, then begin to blink red to orange as it performs DNS. Finally, it will blink green once it has connected to the internet and phoned home to the imp service.
  4. A blue node will appear in your planner
    1. If you've never connected this breakout board before, it will just say "BLANK"
    2. If you've connected an imp in this breakout board before, it will say the same thing it said last time you connected
  5. Now we need to add a new firmware for the joystick.
    1. Open a new tab in your browser and go to https://github.com/tombrew/ei-fw-tom/tree/master/demos/joystick. Copy this code to your clipboard.
    2. Back in the planner, click the "code" button at the top of the screen.
    3. Click the big "+" button on the top left to create a new firmware.
    4. Name your new firmware. I called my "april.joystick".
    5. Now you'll see the electric imp IDE in your browser. Paste the code into the window and hit "save" (the disk button at the top-right). When the code has saved, click "plan" at the top to go back to the planner. 
  6. Now we'll tell the imp to run the new firmware
    1. Click the settings button in the top-right corner of the blue box that represents your joystick. A popup will appear showing your firmwares.
    2. Click the drop-down to display your firmware list and select the new april.joystick firmware. 
    3. In a few seconds, the imp will start to run the new firmware and the text in the planner will change to "APRIL JOYSTICK"
  7. Connect your joystick to some other nodes to control things! To do a quick test, use the "Add node" button to add three "show input" nodes, then click and drag from the "+" on the top right corner of your joystick node to each of these nodes, connecting the X-axis, Y-axis, and button to each. Now you should be able to see the values change as you move the joystick or press the button. You can use the same procedure to "wire" the joystick up to anything else that will except a number as an input - like the impBot!
That's the works! You've got an internet-connected joystick. Go forth and control things!
The Github 404 doesn't load <br>
Fixed now. Do take note: this project uses the old Blueprint environment, but this has now been deprecated in favor of the shiny new API and the powerful new &quot;Agents&quot; feature. Check out the blog post on both here: http://blog.electricimp.com/post/64145825282/electric-imp-rolls-out-agents-to-expand-your-devices
Hopefully, you can show me how to let my PC control this remote controlled lawnmower: https://www.instructables.com/id/Remote-Controlled-Lawnmower/<br> <br> The above web site has a video of my remote controlled lawnmower.<br> <br> Currently, the mower is controlled by a Futaba 4YF transmitter. I want my Windows 7 PC to control the mower either with an interface to the Futaba transmitter or by a PC based joystick and transmitter that replaces the Futaba transmitter. The interface needs to allow the following 2 steps:<br> <br> Step #1-Learn Mode Control the mower via the transmitter and record the sequence of joystick commands to the PC<br> <br> Step #2-Playback Mode Transmit commands recorded on the PC in Step #1 tothe mower.<br> <br> What is the easiest way to accomplish these 2 steps?
Thank you for the simple but great project...

About This Instructable



Bio: Developer at Electric Imp
More by tombrew:NeoWeather: Ambient Weather Indicator Imp Chef: Internet-Connected BBQ Thermometer imPrinter: the Electric Imp wireless, internet-connected thermal printer 
Add instructable to: