Step 7: Program the Trakr

Below is the C Langusage source for the Trakr App:

                                 //relaycontrol app for Spy Video TRAKR.
                                 //Program scans to see if button A was
                                 //pressed on TRAKR remote and sets GPC0 high
                                 //and GPC1 high to send current through
                                 //a relay's electromagnetic coil. This will
                                 //activate the relay's switch closing the
                                 //circuit of an external device.

#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<<7)              //bitmask for pin GPC7 = 10000000

int keyState;                    //define "keystate" as integer

void Start()
JAPI_SetIoOutputMode(GPC0+GPC1);//Set output mode for pins GPC0 and GPC1
bool Run()
    keyState=GetRemoteKeys();    //TRAKR remote control key pressed
                                 //assign to keystate
    if (keyState > 0)
     {                           //if keystate is greater than 0
        {                        //Button A pressed
            JAPI_SetIoHigh(GPC0+GPC1);//Set GPC0 and GPC1 pins high (3.3v)
         } else {
            JAPI_SetIoLow(GPC0+GPC1); //Switch off pins GPC0 and GPC1
        {                        //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

And next is the Make file:

# Makefile for TRAKR Toy
# Trakr Project

PROGRAM_NAME = relaycontrol
PRETTY_NAME = relaycontrol
OUTPUT_PATH = ./Intermediate
INTERNALS_PATH = ../Internals

SOURCES = app.c


SHELL = sh
CC    = arm-elf-gcc
AS    = arm-elf-as
BIN = arm-elf-ld
LD    = arm-elf-ld

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

   @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

   $(RM) -f $(PROGRAM_NAME).bin
   $(RM) -f "$(PRETTY_NAME).bin"
   $(RM) -f $(OUTPUT_PATH)/app.o
   $(RM) -f $(OUTPUT_NAME)
   $(RM) -f $(MKDEPFILE)

   arm-elf-objcopy -O binary $(OUTPUT_NAME) "$(PRETTY_NAME).bin"
   @if [ -d "E:/" ] ; then \
      cp "$(PRETTY_NAME).bin" e:/APPS/ ; \

# End of Makefile

Make sure the Trakr is switched off and connect it to your computer using the yellow USB cable that came with the Trakr. Copy relaycontrol.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 relaycontrol from the menu. Use the Trakr's remote contol to drive the Trakr to a taget. Aim the Trakr's camera directly at the target and press button A on the remote control to fire foam darts at the target.

Congratulations! In this Instructable you learned how to hack the Spy Video Trakr. You learned how to download and install the C language compiler for the Trakr. You learned how to compile a simple program and install it on the Trakr and then run this simple program. Next you learned how to open up the Trakr, attach jumper pins to the GPIO connections on the main circuit board of the Trakr. You learned how an electronic relay works, what the electronic scematic diagram for a relay looks like, and what an actual electronic circuit diagram in which the relay is used looks like. You learned how to make conversion cables to connect the Trakr to external devices. You learned how to make a larger cargo deck for the Trakr and mount a foam missile launcher platform on the Lego cargo deck. You learned how to tap into the Trakr's 9 volt and 5 volt power supplies. You also learned how to use the electronic relay to control a foam dart missile launcher. Finally you learned how to write and compile a program to fire missiles from the foam missile launcher and install it on the Trakr and then run the program. 

About This Instructable


27 favorites


Bio: You can try my projects AT YOUR OWN RISK. There's infinite ways to damage or destroy persons and property. I can't think of ... More »
More by KRA5H: Variable Speed Fan With Snap Circuits, Kano Computer Blink Snap Circuits LED With Kano Computer LaserOscope
Add instructable to: