1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.
2. A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.
3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.
–Isaac Asimov
It has been a while since I have updated Fun With Snap Circuits, but I have been busy with creating some Instructables. Also, my hack adding a grabber arm to the Spy Video Trakr has been featured on several blogs:
Hack A Day:
http://hackaday.com/2011/11/03/bomb-disposal-robot-with-lego-gripper/#more-60341
Dangerous Prototypes:
http://dangerousprototypes.com/2011/10/22/spy-video-trakr-with-lego-robot-arm/
Hacked Gadgets:
http://hackedgadgets.com/2011/09/19/spy-video-trakr-claw-attachment-hack/
Build Lounge:
http://www.buildlounge.com/2011/09/20/spy-trakr-gets-a-claw/
So, in this blog post I have decided to introduce the subject of robotics using Snap Circuits. You will learn how to build a simple Snap Circuits programmable robot.

First, you will learn how to install the PICAXE Programming Editor (the PICAXE is the microcontroller, or computer brain for your Snap Circuits programmable robot, or Roverbot). Next, you will learn what a simple PICAXE program looks like and what it does. Then you will learn about the various parts and electronic components used to build the Roverbot. You will then assemble the Roverbot. Finally you will learn how to program and test the Roverbot.
To build the Roverbot, I used parts from three different sets, the Snap Circuits Motion Detector, Snap Circuits Rover, and Snap Circuits Micro. Elenco does not currently have a Snap Circuits programmable robot product. I find this surprising since Elenco has developed the Snap Circuits Rover, which is a remote controlled rover and the Snap Circuits Micro that teaches you how program the PICAXE microcontroller and how to build circuits for the PICAXE, but Elenco has yet to develop a product that combines the PICAXE with the Snap Circuits Rover.
I designed the Roverbot to be easy to build completely out of Snap Circuits parts and easy to program.
The following are the Snap Circuits parts you will need to build the Roverbot (parts can be ordered separately from Elenco http://www.elenco.com/product/productlist/snap_circuits®; or C & S sales http://cs-sales.net/sncirepa.html):
Software CD from the Snap Circuits XP or Snap-Micro I kit (if you do not have either of these kits you can download the PICAXE Programming Editor from http://www.picaxe.com/Software/PICAXE/PICAXE-Programming-Editor/)
10 X 7 Plastic Base Grid
Snap Circuits Rover
9 volt Battery Block B5
Motor Control IC U8
8 Pin Socket U14 With PICAXE 08m Installed
4 1K Ohm Resistors R2
Slide Switch S1
USB Programming Cable
(You may substitute the Snap Circuits USB to DB9 Converter and the Snap Circuits DB9 Programming Cable if you do not have the USB Programming Cable)
Snap Circuits Micro Software CD
3 Single Snaps
9 Two Snap Conductors
1 Three Snap Conductor
2 Four Snap Conductors
1 Seven Snap Conductor
1 Orange Jumper Wire (Orange)
1 Yellow Jumper Wire (Yellow)
1 Green Jumper Wire (Green)
1 Purple Jumper Wire (Purple)
1 Gray Jumper Wire (Gray)
1 White Jumper Wire (White)
What’s a compiler? Have you seen those geeky T-shirts that say “there are only 10 types of people in the world: those who understand binary, and those who don’t?” If you find yourself scratching your head instead of laughing hysterically, then you don’t understand binary. Computers, on the other hand, understand only binary. 1s and 0s. On and off.

The “pause” process tells the PICAXE to wait 10000 miliseconds, or ten seconds. This means pin 4 will remain high for 10 seconds thus continuing to send current to the motor for ten seconds (the motor will spin for ten seconds).
The data flowchart symbol contains the command “low 4.” It tells the PICAXE to turn the pin off, or to output 0 volts. This will cut power to the pin and the motor connected to it will stop spinning.
If you want to see what the BASIC code looks like, you can click Flowchart and then click Convert Flowchart to BASIC. The code will look like the the following (Note: I added the in-code comments for clarity):
‘BASIC converted from flowchart:
‘C:\DOCUMENTS AND SETTINGS\DESKTOP\SNAPROVERBOT.CAD
‘Converted on 10/30/2011 at 20:53:11
main:
pause 1000 ‘Tells the PICAXE to wait 1000 miliseconds (1 second)
high 4 ‘Sets pin 4 high, which sends current to pin 4 (if there is a motor connected it will spin)
pause 10000 ‘Tells the PICAXE to wait 10000 miliseconds (10 seconds–motor will spin for 10 seconds)
low 4 ‘Sets pin 4 low, or ouputs 0 volts. This cuts the power to the pin and the motor stops spinning.
Leg 8 (snap 8): This is GND or Negative (-) for the PICAXE


The rover has a battery compartment for six AA batteries to power the motors with 9 volts.Disanvantages:It is not designed to have attachments such a robotic grabber arm attached to it.You must be careful to design your circuit so that you do not accidently pass the 9 volts from the rover’s battery pack through the PICAXE microcontroller since this will most likely damage the PICAXE.
The motor in the center is connected to 9 volts of power and ground by four switches (S1, S2, S3, and S4). With all four switches off, the motor will not get any power and the motor will not turn.
The H-bridge is a very simple circuit. Unfortunately it would be impractical to use manual switches to drive a motor. Several companies make H-bridge integrated circuits (ICs) that are easy to use by simply applying power to a particular pin also called “setting the pin high” to drive the motor in one direction. Cutting the power to that pin and applying power to another pin will drive the motor in the opposite direction. The circuitry inside the H-bridge ICs is somewhat complicated, so most folks will choose to use an H-bridge IC rather than building the circuit themselves.
10 X 7 Plastic Base Grid
Snap Circuits Rover
9 volt Battery Block B5
Motor Control IC U8
8 Pin Socket U14 With PICAXE 08m Installed
4 1K Ohm Resistors R2
Slide Switch S1
USB Programming Cable
(You may substitute the Snap Circuits USB to DB9 Converter and the Snap Circuits DB9 Programming Cable if you do not have the USB Programming Cable)
Snap Circuits Micro Software CD
3 Single Snaps
9 Two Snap Conductors
1 Three Snap Conductor
2 Four Snap Conductors
1 Seven Snap Conductor
1 Orange Jumper Wire (Orange)
1 Yellow Jumper Wire (Yellow)
1 Green Jumper Wire (Green)
1 Purple Jumper Wire (Purple)
1 Gray Jumper Wire (Gray)
1 White Jumper Wire (White)
Here’s what the roverbot will look like:

I’ve divided up each function into columns to make the flowchart easier to read.
‘Converted on 10/30/2011 at 20:53:11
main:
‘Snap Rover programmable robot
‘
‘Test left forward
pause 1000
high 0
pause 2000
low 0
‘Test left backward
pause 1000
high 1
pause 2000
low 1
‘Test right forward
pause 1000
high 2
pause 2000
low 2
‘Test right backward
pause 1000
high 4
pause 2000
low 4
‘Test forward
pause 1000
high 0
high 2
pause 2000
low 0
low 2
‘Test backward
pause 1000
high 1
high 4
pause 2000
low 1
low 4
‘End program
stop
In 1947, Grace Murray Hopper was working on the Harvard University Mark II Aiken Relay Calculator (a primitive computer). On the 9th of September, 1947, when the machine was experiencing problems, an investigation showed that there was a moth trapped between the points of Relay #70, in Panel F. The word went out that they had “debugged” the machine and the term “debugging a computer program” was born.
[Although Grace Hopper was always careful to admit that she was not there when it actually happened, it was one of her favorite stories.]
What’s a relay? You’ve probably seen a relay race where one runner hands off a baton to another runner. Similarly, an electronic relay hands off control from one circuit to another. A relay is a very simple device consisting of an electromagnet, an armature (a switch that closes when attracted by the electromagnet), and a spring that is connected to the armature. You can see in the diagrams above how the relay works.
In Figure 1 above, there are two circuits. The first circuit is a battery (3 volts), a switch and an electromagnet. The second circuit is a battery (6 volts), a light bulb and the relay’s armature. While the switch to the electromagnet is off, no current can flow from the 3 volt battery through the electromagnet. So, the armature-switch is off and no current can flow from the 6 volt battery to power the lamp in the second circuit.
In Figure 2 the switch to the electromagnet circuit is switched on. When current from the 3 volt battery flows through the electromagnet, the electromagnet creates a magnetic field that attracts the armature to close the circuit to the lamp. Now current can flow from the 6 volt battery to the lamp, and the lamp lights up.
If you look closely at Figure 2, you’ll notice that while the armature-switch is closed allowing the current in the lamp circuit to flow from the 6 volt battery to the lamp, it does not come into contact with the electromagnet so, the 6 volts from the lamp circuit cannot flow into the electromagnet circuit. Thus, the 3 volts in the electromagnet circuit and the 6 volts in the lamp circuit remain separate.
Above is the electronic schematic diagram of a relay. The curly line represents the electromagnetic coil and the vertical lines represent the metal core the coil is wrapped around. The switch at the top of the diagram represents the armature.
Above is the electronic schematic of the circuits from figures 1 and 2.
The above diagram shows how to build the circuit from Snap Circuits.
When you press the press switch (S1) you will hear the relay click as current passes from the 3 volt battery block (B1) through the electromagnet. The electromagnet creates a magnetic field that attracts the metal armature and closes the circuit to power the lamp. This allows current to flow from the two 3 volt battery blocks (also labeled B1)connected in series (for a total of 6 volts) through the lamp and it lights up.
When you release the press switch you will hear the relay click again since the current has been cut from the electromagnet. This causes the electromagnetic field to collapse so the armature is no longer attracted by the electromagnet and the spring attached to the armature returns the armature to its rest position. This opens the lamp circuit which cuts the current from the batteries to the lamp and the light goes out.
Here’s another circuit you can build that includes the snap circuits motor:
Here’s a video of the circuit in action:
We cannot, by total reliance on law, escape the duty to judge right and wrong…. There are good laws and there are occasionally bad laws, and it conforms to the highest traditions of a free society to offer resistance to bad laws, and to disobey them. ~Alexander Bickel
While you were building the LED project from my last post you noticed that you had to add a 100 ohm resistor to limit the current flowing through the LED to protect it. If you put too much current through an LED, it will burn out. With a POP! And sometimes pieces of plastic will fly off (“you could put an eye out with that”). And it will stink. Then you’ll have to buy a new LED.
Going back to the waterpipe analogy:
When water flows through a pipe, the pipe offers very little resistance to the flow of water.
If, however, a bunch of rocks are inserted into the pipe, this will increase the resistance against the flow of water through the pipe:
As electrons flow through a wire or conductor, there is very little resistance to the electron flow. If you were to connect an LED directly to the Snap Circuits battery block without a current limiting resistor too much current will flow throught the LED and POP! Another way to think of it is filling a water balloon with a garden hose. If you put a kink in the hose this will limit the flow of water making it easy to fill the water balloon, but if you let go of the kink in the hose, the water balloon will fill too quickly and burst.
There are five Snap Circuits resistors: the 100 ohm (the one you used in the LED circuit), 1K ohm (“K” stands for “Kilo” which means “one thouand” so, 1K ohm means ”one thousand ohms”), 5.1K ohm, 10K ohm, and 100K ohm resistors.
Ohm is a unit of electrical resistance. The higher the ohm value, the higher the resistance. The Snap Circuits 100K ohm resistor (100,000 ohm resistor) has a much greater resistance value than the 100 ohm resistor.
There are wirewound resistors, metal film resistors, and several other ways to manufacture resistors, but the most common is the carbon resistor and appears to be the kind of resistor used in Snap Circuits. The materials used in carbon compositon resistors are a combination of finely ground carbon dust similar to the graphite in your pencil (the conducting material) and clay powder (the non-conducting material). By mixing different amounts of carbon and clay together resistors are made to have different resistance values. If more carbon (the conducting material) is added, the resistor will have lower resistance. Which Snap Circuits resistor will have more conducting carbon powder and therefore lower resistance, the 100 ohm resistor or the 100K ohm resistor?
Metal wires, or connecting leads are attached at each end of the resitor and the resistor is protected by a plastic or paint insulating coating.

- Diagram of resistor. Source: http://www.electronics-tutorials.ws/resistor/res_1.html
Connecting Resistors in Series
Since there are only five kinds of Snap Circuits resistors, what would happen if you needed to limit the current flowing through an electronic component but didn’t have a single resistor that matched the value of the resistance that you needed? Let’s say that you needed 200 ohms of resistance. If you used the 100 ohm resistor, it won’t limit the current enough and you might burn out the component. If you used the 1K ohm resistor, it might limit the current too much and the circuit might not work. To solve this problem you can connect two 100 ohm resistors in series to limit the current by two hundred ohms.
In the diagram below, imagine that the battery is a pump and the paddle wheele is a resistor limiting the current:

Single resistor in a circuit. Source: http://faculty.wwu.edu/vawter/PhysicsNet/Topics/DC-Current/WaterFlowAnalog.html
In the next diagram, there is still a single battery, but a second paddle wheel has been added to represent a second resistor connected in series:

- Two resistors connected in series. Source: http://faculty.wwu.edu/vawter/PhysicsNet/Topics/DC-Current/WaterFlowAnalog.html
If the first paddlewheel, or resistor labeled “R1″ is 100 ohms and the second resistor labeled “R2″ is 100 ohms, then the total resistance introduced into the circuit is 200 ohms.
Connecting Resistors in Parallel
Now let’s say that you only needed 50 ohms resistance, but the lowest ohm value Snap Circuits resistor is 100 ohms. You can connect two 100 ohm resistors in parallel and reduce the resistance to 50 ohms. The diagram below may help you to understand what is happening with the two 100 ohm resistors in parallel:

Rsistors in Parallel. Source: http://faculty.wwu.edu/vawter/PhysicsNet/Topics/DC-Current/WaterFlowAnalog.html
“On life’s journey faith is nourishment, virtuous deeds are a shelter, wisdom is the light by day and right mindfulness is the protection by night. If a man lives a pure life, nothing can destroy him.”
–Buddha
In my previous post where I hacked the Spy Video TRAKR, I needed to test the program that I wrote using a Light Emitting Diode (LED) that I scavenged from an old computer. When I pressed button A the LED lit up, but when I pressed button B the LED did not light up. LEDs allow current to flow in on direction but not in the reverse direction. To understand why, build the circuits in projects #7 and #8:
Here’s some additional information about Light Emitting Diodes by Ariel Churi from Sparkle Labs:
Light Emitting Diode from Sparkle Labs on Vimeo.
‘E’s not pinin’! ‘E’s passed on! This parrot is no more! He has ceased to be! ‘E’s expired and gone to meet ‘is maker! ‘E’s a stiff! Bereft of life, ‘e rests in peace! If you hadn’t nailed ‘im to the perch ‘e’d be pushing up the daisies! ‘Is metabolic processes are now ‘istory! ‘E’s off the twig! ‘E’s kicked the bucket, ‘e’s shuffled off ‘is mortal coil, run down the curtain and joined the bleedin’ choir invisibile!! THIS IS AN EX-PARROT!! –Monty Python’s Flying Circus, “Dead Parrot Sketch”
Let’s take a short break from Snap Circuits.
I have the Spy Gear TRAKR.
It is a remote control tank that comes with a color digital video still camera and microphone. It is also programable. You can use the the TRAKR website to design your own applications (apps) for the TRAKR or you can download apps created by other TRAKR owners. If you are good at C language programming (I’m not unfortunately), you can write and compile your own programs for the TRAKR.
Here’s a link to the TRAKR’s FAQ page: http://www.spygear.net/help/faq.php
The most interesting thing about the TRAKR is that the engineers at Wild Planet have designed the TRAKR to be hackable, and lots of folks have been bitten by the TRAKR hacking bug.
Here are some Hackaday articles regarding the TRAKR:
http://hackaday.com/2010/05/24/bamf2010-spy-trakr-no-lasers-14861-cheaper/
http://hackaday.com/2010/08/27/spy-video-trakr-first-impressions/
http://hackaday.com/2010/08/30/spy-video-trakr-the-teardown/
http://hackaday.com/2010/09/02/spy-video-trakr-software-and-first-hack/
Here are the FCC Pages for the TRAKR
Here’s additional documentation:
W55VA91 Design Guide:
http://dl.dropbox.com/u/4295670/W55VA91_DesignGuide%28fullset%29%20-%20A4.pdf
ARM926EJ-S Technical Reference Manual:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0198e/DDI0198E_arm926ejs_r0p5_trm.pdf
ARM926EJ-S Technical Reference Manual Online Version:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0198e/index.html
Information on the nRF24L01 (Radio Transceiver Chip) :
Data Sheet: http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01
TRAKR Remote Startup Radio SPI Traffic: https://raw.github.com/gist/1250231/trakr-remote-startup.txt
Building Bare-Metal ARM Systems with GNU: Part 1 – Getting Started:
We’ve also created Wiki for the Trakr:
http://www.trakrhakr.com/wiki/
Alien Trakr:
I decided to try my own hack on the TRAKR based on the Uni-Directional Wi-Fi Extender posted by tm36usa on the Instructables web site: http://www.instructables.com/id/Uni-Directional-WIFI-Range-Extender/
Here’s what my TRAKR looks like with the strainer attached:
This is only a temporary attachment. I’ll try to test it this weekend to see if I get any better range.
UPDATE: I was able to test the the unidirectional antenna over the weekend. The results were disappointing. I was unable to detect any extension in range with the strainer attached.
If I do say so myself, the TRAKR does look pretty cool with the strainer attached. Unfornuately the strainer serves no other function except aesthetic, but perhaps I should not be discouraged. There may be other ready-made household items that might work to extened the range of the antenna–a small wok, maybe or some other parabolic item that would help to focus the radio waves on the antenna.
Of course, since this is a blog about Snap Circuits in later blog posts I hope to show you how to connect Snap Circuits to the TRAKR.
Two of the Snap Circuit sets I have are the Snap Circuits Rover (SCROV-10), a radio controlled Snap Circuits vehicle, and Snap Circuits Micro which includes the PICAXE 08M microcontroller. There are some intruguing possibilities given the H-Bridge integrated circuit fromt the Snap Circuits Rover and the PICAXE 08m–we can write programs to control the TRAKR using Snap Circuits!
Adding a Lego Cargo Deck:
Here’s a fun fact: The mounting holes for the TRAKR deck attachment are just wide enough in diameter so that Lego cross axles fit snugly into them, which means a Lego deck can be built for the TRAKR without having to hot glue them to the TRAKR. This should make it easy to attach the Snap Circuits base plate on the TRAKR.
UPDATE: As I said I discovered that lego cross-axles fit snugly into the holes for the deck attachment. Here as a lego deck that I built for the TRAKR:
Here are the deck supports made from lego cross-axles:
Adding a Lego Grabber Arm:
I mounted my lego grabber arm onto the deck using the holes in the lego Technic beams:
The Lego grabber arm I used was from the book Robot Invasion by Dave Johnson, but here is a link to detailed instructions of another Lego grabber arm using the original Lego Mindstorms (not the NXT) technic parts:
http://pille.iwr.uni-heidelberg.de/~mindstorms/data/GrabberArm.pdf
Adding Temporary Jumper Pins to the Mainboard GPIO Lines:
UPDATE: I was able to add jumper pins to the 9 GPIO lines. Sorry for the blurry pictures:
UPDATE:
If you are just too squeamish to take the mainboard out of the Trakr and solder the pins down, Sparkfun makes solderless jumper pins that snap into the GPIO holes.
http://www.sparkfun.com/products/10527
Download and Install the C Language Compiler for the Trakr
UPDATE:
I finally got the TRAKR compiler to work (after a bit of tinkering), yay!
What’s a compiler? Have you seen those geeky T-shirts that say “there are only 10 types of people in the world: those who understand binary, and those who don’t?” If you find yourself scratching your head instead of laughing hysterically, then you don’t understand binary. Computers, on the other hand, understand only binary. 1s and 0s. On and off.
I have heard of some people who can do binary code, or machine language in their heads, but the rest of us normal people would have a difficult time writing a computer program out of nothing but 1s and 0s. Instead we use a higher level language like C language to write software.
Have you ever been to a foreign country and didn’t know the language? You can hire a translator to translate what you say into the language that the locals can understand. That’s what a compiler does. Computers can’t understand C language so, a compiler translates the software you write in C language into machine code, or the 1s and 0s that computers can understand.
You’ll need to download and install the C language compiler so that you can write programs for the Trakr and compile your software into machine language that the Trakr can understand. The C Language compiler is included in a fairly complete software development kit (SDK) that the folks at Wild Planet call the “Primer.” So, download the Primer and save it on your computer where it’ll be easy to find by clicking the following link:
http://www.spygear.net/help/files/TRAKR_APP_PRIMER_V1.2.zip
Wherever you decided to save the file it will look something like this:
Make a new folder in the root directory of your hard drive (usually the C: drive) called C:\trakr. Then open the Trakr Primer zip file you downloaded from the Trakr web site and copy all the files and folders from the Trakr Primer zip file into your C:\trakr folder. It should look like this:
Next you’ll need to edit the environment variables to include the path to the Primer’s compiler and tools. If you don’t know what environment variables are, don’t worry, you’re just telling your computer where to find the compiler and the tools it needs to compile your Trakr programs.
If you are using a Windows Vista or Windows 7 computer, click the Start button, right-click Computer on the right of the start menu, and select Properties.
If you are using a Windows XP computer, click the Start button, right-click My Computer on the right of the start menu, and select Properties.
If you are using Windows Vista or Windows 7, click the Start button, right-click Computer on the right of the start menu, and select Properties, then select Advanced System Settings at the Control Panel window.
The System Properties window will open. Then click on the Advanced tab.
Click the Environment Variables button.
In the Environment Variables window, look in the System Variables list for the variable called Path, and click it to select it. Click the Edit button to pop up a window to edit the value of the Path variable.
You have to add some extra text to the end of the “Variable value” text box so, click into the text box press the End key on the keyboard to move to the end of the existing text. Add the following, including the semicolon at the end of the stuff that is already in the text box:
;C:\Trakr\Tools\bin;C:\Trakr\Tools\utils
When you’re done, click the “Ok” buttons on all the windows you just opened to close them all. You are now finished installing the Primer. That was pretty easy wasn’t it? Next we are going to compile a sample Trakr app that is included with the Primer to make sure everything is working ok.
Open a command prompt, which is a Windows text based interface. Go to Start->Programs->Accessories->Command prompt. You will see a flashing cursor after the “>” and you can type text based commands. When you’re done typing a command press the Enter key on your keyboard to execute the command.
If, for some reason you were unable to set the Environmect Variables as instructed above, you can also set them at the command prompt. At the command prompt, type the following commands:
cd trakr setup cd Internals
Your screen should look like this:
So, running the “setup” file executed the command to enter the the Environment Variables for you.
The compiler runs when you type “make” at the command prompt so you need to make sure you navigate to the folder where the makefile you want to run is located. The compiler then follows any instructions in that “makefile” to convert the “app.c” file (the text file containing the source code) into a TRAKR program.
The compiler only looks for the “app.c” file in the current folder so always name your source code app.c. Save your programs in separate folders with names which make sense. This helps to keep all the various “app.c” files organized. In the screen shot below, you’ll want to run “make clean” in the C:\Trakr\Internals folder. It reports all the files it is removing before returning the prompt to you. Then type “make” at the command prompt and the compiler will use the “makefile” to assemble all the parts of your program (which may include many libraries, images and files specified by your code) into a .bin file to write to the TRAKR hardware. At the “C:\Trakr\Internals>” prompt type:
At the “C:\Trakr\Internals>” prompt type:
make clean make
Your screen will show the following:
Your newly compiled program or app for the Trakr is called “Test.bin” and the file will need to be copied to the Trakr. Make sure the Trakr is switched off and connect it to your computer using the yellow USB cable that came with the Trakr. Copy Test.bin to the APPS folder inside the Trakr folder. Disconnect the Trakr from your computer and switch the Trakr on. Switch the Trakr remote on, click the home button, and select Test from the menu. It’s just a little app that tests all the various functions that your Trakr can do such as motor tests, screen functions and so on.
First Compile of Test App:
The following was my humble attempt at writing code in C Language for the TRAKR:
////////////////////////////////////////////
//LED flash program for Spy Video TRAKR
//Program scans to see if button A was
//pressed on TRAKR remote and sets GPC0 high
//and GPC1 low to send current through LED
//in forward bias direction (switched on).
//
//If button B is pressed, it sets GPC0 low
//and GPC1 high to send current through
//LED in reverse direction (switched off).
///////////////////////////////////////////
#include "svt.h" //include Official API
#include "JAPI.h" //include "Secret sauce" API
#define GPC0 (1<<0) //bitmask for pin GPC0 = 00000001
#define GPC1 (1<<1) //bitmask for pin GPC1 = 00000010
#define GPC2 (1<<2) //bitmask for pin GPC2 = 00000100
#define GPC3 (1<<3) //bitmask for pin GPC3 = 00001000
#define GPC4 (1<<4) //bitmask for pin GPC4 = 00010000
#define GPC5 (1<<5) //bitmask for pin GPC5 = 00100000
#define GPC6 (1<<6) //bitmask for pin GPC6 = 01000000
#define GPC7 (1< 0)
{ //if keystate is greater than 0
if(keyState&KEY_INPUT1)
{ //Button A pressed (motor forward)
JAPI_SetIoHigh(GPC0);//Set GPC0 pin high (3.3v)
} else {
JAPI_SetIoLow(GPC0); //Switch off pin GPC0
}
if(keyState&KEY_INPUT2)
{ //Button B pressed (motor reverse)
JAPI_SetIoHigh(GPC1);//Set GPC1 pin high (3.3v)
} else {
JAPI_SetIoLow(GPC1); //Switch off pin GPC1
}
if(keyState&KEY_HOME)
{ //if Home button pressed
return false; //this will end the loop
}
}
return true; //loop will repeat until false
}
void End()
{ //Program end - switch off both pins
JAPI_SetIoLow(GPC0+GPC1);
}
The following is the make file (please note that I have named the program “trakrmotorcontrol” since the same program can be used to flash an LED or drive a motor):
# Makefile for TRAKR Toy
# Trakr Project
TRACKR_PATH = C:/Trackr
PROGRAM_NAME = trakrmotorcontrol
PRETTY_NAME = trakrmotorcontrol
OUTPUT_PATH = ./Intermediate
OUTPUT_NAME = $(OUTPUT_PATH)/$(PROGRAM_NAME).elf
INTERNALS_PATH = ../Internals
SOURCES = app.c
S_OBJECTS = $(OUTPUT_PATH)/app.o
OBJECTS = $(S_OBJECTS) $(INTERNALS_PATH)/trakr.a
SHELL = sh
CC = arm-elf-gcc
AS = arm-elf-as
BIN = arm-elf-ld
LD = arm-elf-ld
TOPMEMORY=0xFFE7C000
CFLAGS = -O0 -I../Internals/Include -I../Internals -Wall -gstabs+
TARGET_FLAG = -mcpu=arm926ejs -mapcs-32 -mlittle-endian -specs=specs.semi
LDFLAGS = -T ../Internals/WJ_APP_8M.ld -Wl,--defsym -Wl,__stack_base=$(TOPMEMORY) -Wl,-Map -Wl,$(basename $@).map -nostartfiles -static
all: prebuild $(OUTPUT_NAME) postbuild
$(OUTPUT_NAME): $(OBJECTS)
@echo "Linking... "
@echo "Creating file $@..."
@$(CC) -u _start -o $@ $(INTERNALS_PATH)/trakr_start.a $(OBJECTS) $(TARGET_FLAG) $(LDFLAGS)
$(OUTPUT_PATH)/app.o:app.c Makefile
@echo "Compiling $<"
@$(CC) -c -o "$@" "$<" $(TARGET_FLAG) $(CFLAGS)
.PHONY: clean prebuild postbuild
clean:
$(RM) -f $(PROGRAM_NAME).bin
$(RM) -f "$(PRETTY_NAME).bin"
$(RM) -f $(OUTPUT_PATH)/app.o
$(RM) -f $(OUTPUT_NAME)
$(RM) -f $(MKDEPFILE)
postbuild:
arm-elf-objcopy -O binary $(OUTPUT_NAME) "$(PRETTY_NAME).bin"
@if [ -d "E:/" ] ; then \
cp "$(PRETTY_NAME).bin" e:/APPS/ ; \
fi
prebuild:
# End of Makefile
When you compile the above code with the above make file, this will create a Trakr App file called “trakrmotorcontrol.bin” and the file will need to be copied to the Trakr. Make sure the Trakr is switched off and connect it to your computer using the yellow USB cable that came with the Trakr. Copy trakrmotorcontrol.bin to the APPS folder inside the Trakr folder. Disconnect the Trakr from your computer and switch the Trakr on. Switch the Trakr remote on, click the home button, and select trakrmotorcontrol from the menu.
I simply connected an LED to GPC0 and GPC1. I got the LED from an old computer. The LED was a power indicator LED and connectected directly to the PC motherboard with jumper connectors. Thus I was able to connect the LED to the headers in GPC0 and GPC1. Pressing button A on the Trakr remote turned the LED on and and pressing button B turned it off as expected.
To show what is happening when pushing the buttons on the Trakr remote I created the following LED circuit using Snap Circuits:

The black Snap Circuit jumper wire is connected to GPC1. It is connected to a 100 ohm Snap Circuit resistor block that is connected to a Snap Circuit green LED block by a two snap conductor. The red Snap Circuit jumper wire is connected to GPC0.

When I push button B on the Trakr remote GPC1 is pulled high and GPC0 is pulled low. Current flows through the LED in the “forward bias” direction (the direction of the arrow printed on the green LED Snap Circuit block) and the LED lights up. Why do you suppose the LED will not light up when I press button A?

To get the LED to light up when I press button A, I have to reverse the circuit. When I push button A, GPC0 is pulled high, GPC1 is pulled low, and with the circuit reversed current can now flow in the forward biased direction of the LED and light it up.
Next I connected a Snap Circuits motor. Pressing button A turned the motor in forward direction and pressing button B turned the motor in the reverse direction as expected.
Now the motor will turn in forward direction as long as I hold button A down and stop when I release it. It will turn in the reverse direction as long as I hold down button B and will stop when I release it.
I used my HDD indicator LED to connect my Lego Technic motor. I cut the wires to the LED and stripped the ends and connected them to my Lego motor. Unfortunately, trying to power my lego motor with only 3.3 volts is not sufficient power to operate my lego grabber arm–it moves very slowly and opens or closes he grabber but stops when the additional torque is required to raise or lower the grabber arm.
Since a lego motor requires 9 volts I decided to start actually hacking the TRAKR and that meant taking apart the TRAKR and breaking out the soldering iron. Since this is a blog about Snap Circuits, I decided to incorporate snap circuits into the hack.
First I took a red and black Snap Circuits Jumper wires
…and cut them in half.
I stripped the insulation from a red jumper wire half and soldered it to the TRAKR positive input solder point from the TRAKR batteries on the TRAKR main board. I stripped the insulation from a black jumper wire half and soldered it to the TRAKR negative input solder point from the TRAKR batteries on the TRAKR main board.
Now I had a 9 volt source of power from the TRAKR batteries.
Next I needed and external circuit to take an input from the GPIO pins on the TRAKR main board which is only 3.3v and then drive the Lego motor that needs 9 volts. Luckily Snap Circuits has just the block I needed. If you have the Snap Circuits Rover, SCROV10, then you can use the Motor Control IC for the Snap Rover:
Here’s a description of the motor control block, including pinouts, from the Elenco website:
If you are familiar with H-bridge ICs you’ll notice that the Snap Circuits Motor Control block is very similar to an H-Bridge IC.
I connected the red Snap Circuits jumper wire that was soldered to the TRAKR mainboard 9 volt power to the “+” snap on the Snap Circuits Motor Control block. I connected the black Snap Circuits jumper wire that was soldered to the TRAKR mainboard ground to the “-” snap on the Snap Circuits Motor Control block.
I took the other half of the red Snap Circuits jumper wire and stripped some of the insulation and connected it to the wire that was connected GPC0 (after disconnecting it from my lego motor). I did the same with the other half of the black Snap Circuits jumper wire and connected it to the wire connected to GPC1.
Then I was able to connect GPC0 to the LF snap on the Snap Circuit Motor Control block and GPC1 to the LB snap on the Snap Circuit Motor Control block.
Unfortunately I was out of Snap Circuits jumper wires so, I had to connect alligator clips to my Lego motor and used the alligator clips to L- and L+ on the Snap Circuits Motor Control block.
Here are some pictures of my TRAKR with the Snap Circuits Motor Control block connected:

TRAKR With Lego Grabber Arm and Snap Circuits Montrol Control block closeup. The alligator clips are connected from L- and L+ on the Snap Circuits Motor Control block to the Lego motor on the Lego Grabber arm. The red Snap Circuits jumper wire is connected from "+" on the Snap Circuits Motor Control block to the 9 volts solder point on the TRAKR mainboard. The Black Snap Circuits jumper wire is connected from "-" on the Snap Circuits Motor Control block to the Ground solder point on the TRAKR mainboard.
Click the link below to see the grabber arm in action:
My approach was to have a grabber arm for the trakr and see if it could be built from ordinary toys or other items that people might already have as apposed to having to buy special electronic items from Frye’s or Radio Shack or Sparkfun.
So, I was able to use the TRAKR, Legos, and Snap Circuits for the grabber arm.
The only electronic Items that I had to buy were the header pins to insert into the gpio holes on the TRAKR mainboard (BTW the solderless pins are now in stock at spark fun–I plan to get some soon) and shrink tubing.
I got the header pin connector from an old computer I took apart (the LED and header pin connector I used for my intial test was the hard disk drive LED from that computer).
Of course, I already had the soldering iron and some solder.
Elite Trakr Hacker “cpt_hans” Demonstrates How to Solder GPIO Headers:
UPDATE:
For you hardcore hackers, elite Trakr hacker who goes by the handle cpt_hans has kindly provided detailed instructions (with pictures) for taking apart the Trakr and soldering the header pins down:
In this section, I’m going to briefly explain (with the aid of several photos) how I disassembled the Trakr and installed the headers. Please note that this project is not difficult, but it does require some patience and some soldering skill. If you are inexperienced or uncomfortable soldering on a printed circuit board, you can follow the instructions to disassemble the Trakr, and then take it to someone who can solder it for you.
The GPIOs and the A-to-D converter are inputs and outputs that can be used to control things. They share a .1″ pitch header. The JTAG is a programming/testing port that uses a 2mm header. I plan on exploring the JTAG port, to see if I can access some capabilities there…but not everyone may be interested in doing that. I’m going to show both, but you can do just the GPIO if you want.
I ordered part # PRT-10112 ($0.95) from Sparkfun http://www.sparkfun.com for the JTAG header. It’s 10 pins; we only need 7, so we can just snip off the extras. For the GPIO, I ordered part # PRT-00116 ($1.50). It is a 40-pin header. Since we only need 9 pins, that one part is enough for 4 Trakrs!
Here’s the two parts:
You’ll need these additional items for this project:
- Trakr (duh!)
- #1 Phillips screwdriver
- Fingernail polish remover
- Cotton swabs
- Exacto knife (or similar hobby knife)
- Soldering iron
- Solder
- Vacuum desoldering tool (aka ‘solder sucker’…hey, nobody’s perfect, and you may have to fix a mistake!)
Start by removing the two screws for the back cover. Throughout this project, be mindful of the antenna, and don’t break it!
When that’s done, you can look in at the mainboard, and see where we’re going to install the headers.
You’ll want to fold the antenna over and then flip the Trakr over so you can get at the screws that fasten the Trakr case together. Use a philips screwdriver to remove all the case screws (you can ignore the battery and reset compartment screws). There are a total of 12 screws to remove. Note that the screw marked with a star is shorter than the other 11, so keep track of it.
Once the cover screws are removed, you can pull the upper and lower housings apart. When you do, the emblem on the front will fall out. No worries. There’s also another piece behind it that will now be loose. Set them both aside, and remember to replace them when reassembling the Trakr.
With the upper housing moved aside, you can see the shiny screws holding in the mainboard. Resist the temptation and don’t remove them yet!
Once the cover screws are removed it’s easy to lift the cover enough to see most of the main board. When opening up the cover remember to be careful. There are a number of wires that are connected between the cover and the mainboard. The connectors for the wires are modular, but to make the Trakr more rugged, the connectors have been glued together. I don’t know what kind of glue Wild Planet used, but it must be UFO technology from Area 51! It’s tough stuff! This is where the fingernail polish remover and patience are employed.
With a cotton swab, apply fingernail polish remover to the glue to soften it up. It will probably take more than one application. Allow the polish remover time to soak into the glue. Use the hobby knife to trace along the connector joints, and to peel the glue away from the connectors. Note that the connectors also have two tabs molded into the plastic so they’ll latch together. I used the knife to release the tabs, once the glue was cleaned away.
Here’s a couple of views of the connectors that need to be unglued:
With the connectors unglued and separated, you can now set aside the upper housing. If while trying to separate the connectors, you end up pulling the whole thing off the board, don’t fret. The pins on the board will still be okay. If you look at the pic below, you’ll notice that I accidentally pulled the whole connector for the speaker off of the left front leaving the pins sticking up from the board. It was easy to reattach the connectors to the naked pins once I got the connector separated. I just used a hot glue gun to reattach it to the mainboard. Your Trakr will now look like this:

Before you take the mainboard screws out, there’s another connector to unhook. This flat white ribbon cable is on the right front of the Trakr, and is for the camera assembly. It’s a pressure-type connector that holds the ribbon cable against the contacts of the socket. To release, slide the little brown tabs (they’re actually connected and run underneath the ribbon cable) forward about 1/8″…the cable will slide right out.
Remove the five mainboard screws, and unhook the connector to the USB port from the bottom. I left the power leads from the battery pack soldered on, since I had enough freedom of movement even with them connected.
I trimmed the headers to the required number of pins needed. It was easy, since both of them are scribed between each pin for just that reason!

At this point, it’s a simple matter to insert the headers into the holes on the mainboard, and solder them in. Good solder joints are smooth and shiny like these. Ensure that none of them are soldered to their neighbor (solder bridge).
Now reverse the disassembly process to put your Trakr back together!
So you ask, “I have pins, now what do I use for plugs?” You can order connectors online to fit the headers, although Sparkfun doesn’t carry any. I did some scrounging in my parts box and found that various cables from old computers will connect to the headers. The connector on the left is an audio connector used to hook CDROM drives to sound cards or motherboards. It fits the GPIO spacing. The connector on the right is the type used for internal audio connections, like video capture cards to sound cards, etc. This will fit the JTAG spacing.
I’m not saying these connectors will meet all your needs, but it at least you can modify them, and it gives you an idea of what to look for in your junk box. In the pic below, I have two CDROM audio cables on the GPIO…this would give me A-to-D and five GPIO connections; certainly enough to play around with. Other .1″ connectors from an old computer case or motherboard (e.g. front panel switches, USB headers, chassis fans) should be of compatible spacing as well.
I also found that there’s enough clearance from other components for a standard IDE cable to connect to the GPIO header. Of course, you’re only using one row of the connector, and you may want to trim it down…but hey, be a hardware hacker!
“Some people believe that when you die there is a wonderful light. As bright as the sun but it doesn’t hurt to look into it. All the answers to all the questions you want to know are inside that light. And when you walk to it… you become a part of it forever.” –Poltergeist
So far we’ve taken a look at the Snap Circuits basic components such as the battery holder, switches, and wires (snap Conductors). We probably ought to try putting together a simple circuit, which will give us an opportunity to take a look at how each project is discussed in the Snap Circuits manuals. One of the first Snap Circuit projects (depending on the Snap Circuits set you have) is a simple circuit that will switch a lamp on and off. Here’s what the manual page looks like:

Snap Circuits Project #1 (Source: http://manuals.elenco.com/manuals/sc-100%201-101.pdf)
As you can see the projects in the manuals are self explanatory. Three electronic components, the battery holder, the slide switch, and a lamp are connected together with snap Conductors on the plastic base grid.
The next series of photos are a step by step build of the circuit:
When you are done connecting all the components you’ll notice that the labeling on the Snap Circuits blocks look almost exactly like the electronic schematic.
You can click on this link to see an animation of the current moving throught the circuit (place your mouse cursor and left click on the switch to turn the circuit on or off).
You can also build the lamp circuit online by clicking on this link. Here’s what the circuit might look like when you are done:
Unfortunately the Java applet has only a few components to use to build circuits, but is useful right now to help you understand current moving through a circuit.
If hairs be wires, black wires grow on her head. –William Shakespeare (Sonnet 130)
Snap Circuits has several ways to connect the various electronic components together. Each component could be snapped to another, but often, becuase the components are different physical sizes or may be separated by a distance, you will need to use a Snap Conductor–the snap circuits equivalent of an electrical wire.
In the water pipe analogy, electrical wiring is the pipe through which the current flows. Some Snap Circuits conductors actually look like electrical wires with snap connectors attached at the ends and are called “Jumper Wires.”
Mostly, however you will use “Conductors” with one or more snaps.
Snap Circuits Conductors come with a single snap all the way up to seven snaps. A conductor with a single snap is often used when electronic components need to be stacked on top of each other). A Conductor with seven snaps may be used used when two electronic components are far from one another on the base grid.

















































































