loading
Hello! this is my first Instructable :)

This robot is unique because it allows you to edit the code, simply by connecting a keyboard and using the on-board, on-screen code editor! The programming language it uses is simple and easy. It's also pretty awesome you can just plug in a keyboard and edit the code at any time.

I recently made a robot for a competition, the "AFRON $10 robot challenge". The robot had to be under $100 and as close to $10 as possible. I went for the "all in one" category, where the robot has a built in code editor and requires no computer. To make this useful, I   had designed it to have a screen and use a keyboard, while still being cheap. the point is to create a cheap and educational robot, and in my case, one that does not require an external computer to use or re-program.

It's all based around the Sparkfun's "Serial Enabled LCD Kit", hacked and modded with the robot firmware and some re-wiring to allow for the keyboard. It's programmed with the Arduino IDE and the code is available open source.

The software it runs is just about the most special part of the robot. it runs a custom coded NS-BASIC (Not So BASIC, my own programming language) interpreter with some seriously powerful functions and features.


Here are some videos. this first one shows a demonstration with the not entirely finnished Interpreter and editor:

and this video is of firmware 0.2 (still a prototype, might never reach 1.0) and all the fixes and features it adds and stuff:

note: nearly EVERY picture has little notes or annotations or whatever they are called on them, and they could be important, useful, or informative! or sometimes point out the obvious. still, if making this, they might be helpful!

Step 1: Materials

A list of materials needed to make this robot:

from sparkfun:
Serial Enabled LCD Kit
H-Bridge Motor Driver 1A
Male Headers right angle 20 pins
6 Pin Right Angle Female Header
MiniDIN 6-Pin Connector Breakout+ MiniDIN 6-Pin Connector

electronics store (like radioshack in america):
Geared motor set- yellow (I got these from NetRam (an South African company since I live in South Africa http://www.netram.co.za/Electronics/Mechanical/Geared-Motor-Set-Yellow.html?keyword=geared+motor )
Strip board/vero board
9V battery clip
Light Dependent Resistor X2
10K resistor X2
220 uF capacitor 10V or more
5V linear regulator
1 meter of single core wire X3 (red, blue, black)
A switch and a button
Male and Female machine headers (20 pins will do, and you can use "normal" male female headers as well)

general stuff lying around/most supermarkets:
9V re-chargeable battery (a non-rechargeable one will work too)
PS/2 keyboard
Plastic water bottle
Lid X2
Rubber bands X3
Large rubber bands X2
Chopsticks X2





these are the tools you will need:
Decent soldering iron and solder
Drill
Stanley knife or similar
Saw
Wire cutters and strippers (recommended)
Multimeter (recommended)
Programmer
The Programmer is any atmel programmer supported by Arduino, but I HIGHLY recommend you use an Arduino FTDI Serial programmer. both cost $15 on sparkfun, so if you don't have one, get an FTDI programmer. you only use it once, to upload the firmware (or multiple times if you decide to update it to a newer version of course) so I conciser it a tool.



these are the recommended skills:
having used Arduinos before (or at least the IDE)
some soldering skills (not much, but I do not recommend this as a first soldering project!)
I would say programming skill, but you actually don't need it. NS-BASIC is easy, and you can leave a comment/mail if you get stuck.

the following must also be downloaded:
the manual, explaining everything you need to know about NS-BASIC and the code editor here: http://www.mediafire.com/view/?c53e384m4yu8g25 (also contact me if you have problems)
the source code for the interpreter/editor: http://www.mediafire.com/?ipvrd48ejcef5vi
note: This code by Laurens Weyn is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License. http://creativecommons.org/licenses/by-nc/3.0/deed.en_GB

The arduino IDE, here: http://www.arduino.cc
and the keyboard libary for Arduino (include in the Arduino IDE's libary folder) http://www.arduino.cc/playground/Main/PS2Keyboard

Step 2: The Processor

When the parts arrive and everything’s ready, begin by assembling the Serial Enabled LCD Kit. This will be the CPU for the robot. I would write an assembly tutorial, but sparkfun did a much better job than I ever could, so here’s the official tutorial: http://www.sparkfun.com/tutorials/289
Follow this tutorial, but solder the male machine pin headers to those breakout pins at the bottom AND the ICSP header/serial header on the side! This is very important before you attach the screen. It should look like the first picture.

Once assembled and you are using the recommended USB-serial programmer, plug it in and open the arduino Serial console. If you do not have Arduino installed on your computer, get it from www.arduino.cc . preferably version 1.0 over the latest one, since that’s where the code is currently being compiled in. newer ones should work, though. Be sure to install the drivers for your USB to serial converter! Set the board to Arduino Dumilavore with ATmega328 as well! If this is done and typed text in the console appear on the screen (after playing with the contrast dial), congratulations!
Now we are going to have to hack it. Begin by taking the bare bones sketch from the arduino examples and uploading it while your display is still plugged in. once done, the display should turn off and it should tell you the upload was successful.
Turn on the soldering iron and make the following adjustments: (all directions are as if you are facing the board as shown in the above and below picture!)

• Solder a wire from the bottom-middle pin on the ICSP header over to the pin labelled “D2” on the LCD connector (if you are using the ICSP programmer, be sure it can still plug in)
• Solder a wire from the second pin from the bottom right on the chip (see the picture) going left, over to the 4th pin from the top left going right. Hard to explain, please see the picture below.
• Cut the trace connecting the pin labelled “D2” on the LCD header to that pin on the chip we just soldered a wire to. Again, see the pictures.
It should look like picture 1 and 2 (be sure to look at the note at the top of picture 2)

With this done, connect the programmer again and upload the firmware (available on the website) and if you did everything correctly, it should show “NS-BASIC” and a loading bar before crashing (intentional). If so, congratulations! You have finished assembling the CPU. This was one of the harder parts. On to the next step!

Step 3: The Main Board (part 1: Power and Keyboard)

Now that we have the CPU done and working, it’s time to give it a home. picture 1 and 2 is what we will be assembling.

Well OK, only a small part of it for now. Sorry to say this, but it’s actually even harder than it looks (for me it was, I'm not good with soldering on veroboard). But we shall do this in steps! This is the first, and slightly easier part.

Begin by laying out the CPU header (the female machine pin one), the switch, the H-bridge chip, the regulator, the keyboard header, the switch and button like in picture 3.

ignore the wires in place for now. That said, please try use the computer generated layout instead of my pictures, I had to make a lot of changes before it started working on mine. Hopefully you won’t have the same problem, but in my case it was mostly faults in the un-tested design. In fact, for the first half of building this, I didn’t have a design. I just put parts on the board and tried to connect them.
Anyways, when these parts are in place and soldered on, cut the traces at the H-bridge and near the regulator. They are indicated with an X on the design. (pic 1+2)


Add the capacitor (make sure the white, negative side points away from the board!) and add ground wires connecting to the reset button and the regulator/switch, the regulator and the CPU header, the CPU header and the keyboard header. Also add the power wires connecting the regulator to the CPU header and the CPU header to the keyboard header. Then add the battery clip wires. In fact, add all wires and stuff shown in the fourth picture.
Those wires going up are actually the wires from the battery clip. What’s not shown is the underside and the traces you need to cut. By the way, cut all the traces in the diagram at the beginning of this step.
Almost done with step 2! Now connect the battery, and place your finger on the battery clip and the regulator IC to feel if they get warm after about 5 seconds. If they do, disconnect the battery clip immediately (and remove your fingers from the hot parts, they heat up pretty fast!) and if nothing happened, move the switch and wait another 5 seconds. If something heated up, check the connections with a multimeter to make sure none are shorting, and double check to see if your design matches. Also move the switch to the right with the battery plugged in and put your multimeter probes into  the two CPU header pins on the far right (from the above picture, the last 2 pins) and see if there is about 5 volts.
If all is well, disconnect the battery again and put in the CPU/display, and make sure the serial programmer port is on the right, with the regulator. Also, the regulator might need to be moved a tiny bit to the left for the contrast dial to fit in, as shown in picture #5

In that picture, you can also see how the display is supposed to be plugged in.
Now, connect the battery, and move the switch to the right. If all goes well, you should see this familiar screen (picture #6, the last one)

if you see a less blurry version of this, then it’s working! See that small thing on the bottom of the picture? We’ll be making that now.
To make the PS/2 connector, simply take that PS/2 breakout PCB, that PS/2 keyboard jack and that female right angle header and put them together and solder. There isn’t much to it, really. Once this is made, plug in your keyboard on the one side and the other to the plug in front of your robot. It’s recommended to keep the keyboard plugged in and always remove the header, since that’s easier. Press the reset button on the robot and while you see the bootup screen, press any key. You should see the code editor! Hurray! You will also see a lot of white blocks. Push “tab” and then “Y”  to clear everything. Now go read the manual for how the code editor works! You won’t be able to use the drive functions yet (there are no motors connected) or the sensor functions, but you can do math and PRINT and WAIT functions, and play with variables!
Have fun in the code editor to celebrate finishing step 2, because step 3 is a little harder. In my opinion, at least.

Step 4: The Main Board (part 2: Motors and Sensors)

There’s not much to say here, but a lot for you to do. Look at the diagrams and make everything you see, really.

After a lot of soldering and testing, your device should look like picture #3.
Note that the photocells are not included in this picture yet. Those are the 2 circles on the opposite side of the board on the diagram, by the way. It’s a good idea to attach those near the end. You will see why later. Sadly, this means you can’t test if they are working yet at this time either.

What makes this step hard is there isn’t much to it. You can’t test much until it’s all done. If you have any problems with this step, or any step at all for that matter, don’t hesitate to contact me/leave a comment. The wires going to the bottom of this picture will go to the motors. You can test the motors by attaching alligator clips to them and the wires, and running the DRIVE,STOP,LEFT or RIGHT commands. It’s probably a good idea to place your finger on the H-bridge and regulator when powering this up for the first time with or without motors. If it heats, disconnect and check stuff with your multimeter.
If it all works, congratulations once again! Now, we need to turn this mess of wires into a robot. This part is a little easier, and it’s a lot easier to track down problems. In electronics, something heats up or just doesn’t work and seeing the problem can take a few minutes. For mechanics, it’s pretty obvious to see that the robot isn’t driving because the wheel just came off.

Step 5: Mechanics and Motors

OK, let’s begin by attaching the “caster wheel”. A caster wheel is a wheel that has no motor attached to it, and just acts as a stability point. It’s a bit like a trolley wheel, really. In our case, this won’t be a wheel.
Take any old water bottle, and cut it off near the bottom. I cut mine 7.5 CM from the bottom (this is where Valpre bottles are at their thinnest). Now, make another cut about 3 CM from the bottom, but only cut halfway. I made both of these cuts with a saw, but you could use a craft knife as well.
This half-way cut is to connect to the circuit board later. see picture #1. see picture #2 for where it will later be attached.

By the way, the chassis is the circuit board. You will need to cut this to size. Remove the CPU from its socket and take out the saw. My model was cut to just over 11 Centimetres from the electronics side, but this doesn’t have to be exactly this long. Once cut, you can attach the bottle/caster wheel and get the chopsticks, the motors and a knife ready.
Take the sticks and try to put them in the holes in the motor. The holes, by the way, are located near the output shaft, normally for mounting screws. Chances are they won’t fit, but that’s OK. Place the motors at the bottom left and bottom right of the main circuit board and cut both just a little shorter than the motors are.
Yea, OK, this is confusing, it might help if I showed you what we are actually making here. see picture 3 for how we will eventually attach the motors.

It’s not the neatest system, but it is strong enough. Anyways, cut the sticks with the knife or something and then we will make the stick thinner on both sides, like in picture 4.

To do this, take the stick and slide the knife away from you near the end. I’m not sure how to explain this, actually. Anyway, once you are done (you will know this when both sticks fit in the motors and are holding them the correct distance) we will attach the 3 rubber bands. Pretty simple. 1 across, and 2 along the length of the board. Position and move the rubber bands until the motors are in the correct place. Don’t worry if it moves around, this thing is actually really strong.
If you went for the duct tape method, simply do it like you would with anything fixed with duct tape: put it all over the place. Still making the output shaft and connectors accessible, of course. I can’t provide you with help here since I didn’t try this method, but knowing duct tape, it will surely work. One disadvantage is making electrical fixes and changes when the motors are duct taped to it is rather hard.
Now let’s do a little more soldering. Attach the wires to the motors. now I’ll describe witch wire goes to what motor pin. The directions assume you are looking at it from the motors closest to you. The bottom right wire on the chip goes to the bottom pin on the right motor. Bottom left goes to top pin on right motor. Top right pin goes to the top pin on the left motor, and the top left pin goes to the left motor’s bottom pin. No picture, because it’s just as confusing. Don’t worry if you get these wrong, though, this can be fixed trough code. Just get the left and right motors correct and the rest can be fixed. Just contact me for the fix for your particular problem.
While the iron is hot, let’s attach those photocells! In my case, the bottle got in the way of the photocells and where I planned to put them, so with 2 signal wires I moved them to the side.

Not very easy to see stuff from this picture, though. Note 2 things: firstly, this is not in the diagrams as it was not planned, and secondly traces were cut on the far left and right where the new wires connect. I suck at explaining.
You can now attach the bottle caster thing if you haven’t tried to already. We are almost done! Also, you can optionally test the motors now with some DRIVE and LEFT functions, and your photocells with PRINTN [1] or PRINTN [2] in a LOOP.

OK, let’s finally move on to wheels. Take the lids and measure the exact centre of each, and make a mark there. Now, slowly drill a hole with a drill about the size of the motor’s axle. I know it’s a rectangle, but find a drill the width, not height of this shape. Remember: it’s not a square, but a rectangle. Once you made the hole, either make one close to that one (so close it joins) or keep the drill in the hole and press it against the side to extend it that way. Once your oval-ish hole is made, try fit it on the motor shaft. It will probably not fit yet (that’s good, it must be a tight fit) so keep pressing against the sides with the drill until it juuuuust fits on the shaft of the motor with a little pushing. Do the same for the other lid.
If you made your hole too big, you can use prestic or possibly glue to keep the wheel from sliding around.
Optionally, but recommended, you can add rubber bands to the lid for added traction. I used the inside of an old bicycle wheel (the inner part that’s supposed to get inflated, I cut off a piece of that and since it’s rubber and a cylinder, can be stretched around the wheel).
the last picture shows the wheels on the finished robot.

Because you might be using different or no rubber bands, and lids are never the same, yours might not look like this. You could also be using cardboard cut-out wheels.

Step 6: Add-ons/changes (AKA, We Are Done!)

No, that’s it! You have finished your robot! Let’s talk a little about what you have built.
Chances are there’s a lot of space between the bottle and electronics. This is for you to add on! There’s one free analogue port (it’s the second pin from the left) that can be used for whatever you want. It could be any analogue or digital sensor, check the manual for how to read from it.
This device is intended to teach programming in schools, so learn! There’s plenty of functions in the manual, and I will help you with any problems or questions you have.
The photocells don’t have to point right in front. As you can see, I made mine with plenty of the lead coming out of the board, so I can move them. Point them at the floor and you can follow lines, point them between the floor and in front and you can detect objects and corners, point them in front and you can make it drive towards light, point them up and make them find the brightest spot in the room, whatever you want!
I hope you make your robot do some cool things, and if you are a teacher, I hope your class learns a lot from this robot!

need help? contact me at "laurens full_stop weyn at_sign gmail full_stop com". full_stop=".', at_sign="@", and no spaces. spam bots these days...
Nice Work! What does the BOM (Bill of Materials) add up to? Great idea to publish the design here. I'll do the sane with my entry. <br>
it adds up to $63.77, including the keyboard (if bought second hand) and the rechargeable battery, excluding battery charger and $15 programmer (considered a tool) <br>oh, sorry! I meant AFRON! that was a typo :) fixing that now. <br>I'm interested in seeing your entry as well! what category are you going for?
I guess it is in the external programmer category. <br>My official entry is at http://twilltech.com/DuckBot . Not sure when I can get to Instructables to post it. -Chris
wow, that's very professional! my dimensions sketch looks like it was drawn by a 5 year old in paint, I'm serious! I've never been good with 3D designs since I can hardly draw in 2D. <br>would be cool to see it working/built though. that's a very nice anti topple system as well! you should invent a segway without self-balancing technology like that. <br>
BTW: The acronym is AFRON. The N is for Network. Let's get them all published here!
very cool, the on board programming really sets it apart from the rest!
Great work!!! Impressive! It is a good idea to include the on-robot programmer so you can program and test any where any time!

About This Instructable

11,638views

36favorites

License:

Bio: I've always been interested in computers/electronics/robots, and all the things about them. It's now my hobby, and I hope to one ... More »
More by thatdude624:cheap robot with on-board code editor (PS/2 keyboard code input,EEPROM storage) 
Add instructable to: