nxtprograms.com

Fun Projects for your LEGO MINDSTORMS NXT!

Home     Projects     Help     Contacts

Fake GPS Receiver
Building: (none)
Program: Expert

Building Instructions


1

This project requires no building.  All you need to do is download the program to the NXT brick.


Fake GPS Receiver Programming

Use the program GPS for the fake GPS Receiver.  This program is designed to be intentionally tricky and even misleading when you examine it.  But can you figure it out anyway?  Here are some hints:

  • The stuff about "back door" variables and system traps is all fake.  The variables with strange names are just regular NXT-G variables, and they behave in the same way as all variables.  Don't worry if you don't know what a "thread", a "trap", or a "stack" is.  This is all fake mumbo-jumbo.

  • The rebooting into another operating system (a "debug micro-kernel") is fake.  Everything is done using normal NXT functionality.  But can you explain the results you see on screen?

  • Don't get bogged down in the math calculations in the program.  They don't do anything.

  • The comments in the program are designed to be intentionally misleading.  Don't believe what you read.  Look at the what the program blocks are actually doing.

And here are some general techniques to help you figure out how an unfamiliar program works.  You can also use these techniques when you are trying to find a problem with ("debug") your own programs.

  • In a program that contains Switch, Loop, and Sequence splits, it is not always obvious where the program will go when.  To help you figure this out, you can add Sound or Display blocks to the program that will signal to you when the program reaches that point.  For example, if you put a "Hello" sound block at the beginning of a loop, then you will hear the "Hello" each time the loop repeats.  And if you put different sounds in different conditions of a Switch, you will be able to hear which way the switch went.

  • To slow down the normally rapid execution of blocks in a program, to help you trace through it while it is running, you can add Wait blocks that wait for a time delay, a touch sensor, or one of the NXT buttons (e.g. orange Enter button) to be pressed.  This works well combined with the Sound and Display blocks suggested above.  Try adding a Display or Sound block immediately followed by a Wait for the Enter button at a key point in the program.  This will tell you where the program is and give you a chance to notice and think about it before the program continues.

  • To help figure out a program that contains variables (most of the variables in the GPS program are not important, but a few are), try this technique to trace through the program by just looking at the blocks (not running it):

    1. Get out a sheet of paper and a pencil to write variables down on.

    2. Start at the beginning of the program and carefully follow the program flow with the white sequence beams, etc., one block at a time.

    3. Each time a new variable in introduced, write down its name on the paper, and next to it write down the value that was written to the variable.  Any variables that are read before being written will start out with a zero/False/empty value.

    4. Any time a variable is used for a Switch, Math Block, etc., look at your paper to determine the value for the variable.

    5. Any time an existing variable is re-written with a new value, erase or cross out the old value on your paper and write the new value.

  • As an advanced way to debug a program with variables in it while it is running, you can add Display blocks to display the values of certain variables (numbers will need to be converted to text with the Number to Text block then wired into the Text input hub of the Display block), followed by a Sound then a Wait for a button press to give you a chance to notice and read it.

 

Challenges
  • The coordinates that you get from your fake GPS might be different from the ones shown above.  Where does your NXT think you are?

  • Can you figure out how the GPS program works?  How do you explain what you see on screen from the blocks and structures used in the program, including the fake "boot up" part?

Fake GPS Challenge Winners

When this project was first posted, there was a contest to see who could be the first three people to explain how the program works.  Congratulations to the following people for their great detective work and excellent explanations!

Gordon Buchanan
Patrick Dynes
Rong F. Lee

  • Does this project give you any ideas for other fake programs you could come up with to trick your friends?  You don't need to worry about making the program blocks confusing, since your friends won't see the program, just make the end result on the screen look like something they might believe.  Here are some ideas:

    • A fake "Lie Detector" using the light sensor to "measure" their skin temperature.  After saying something into the sound sensor and pressing the touch sensor, the NXT will display either "True" or "Lie".  Perhaps randomly, or using some other pattern trick you come up with (such as every third statement is labeled as a lie).

    • Similar to a lie detector, perhaps a "Magic 8 Ball", that randomly comes up with answers like "Not Likely", "Yes", "No way", etc.

    • A fake text messaging application.  Pretend that you can carry on a text conversation with someone else (like texting on a cell phone). 

    • A fake metal detector.  Use the NXT to scan your friends and locate metal in their pockets, etc.

    • What else?

Get nxtprograms.com on CD!
Click here for info

Home     Projects     Help     Contacts

 

Copyright 2007-2011 by Dave Parker.  All rights reserved. 
All project designs, images, and programs are protected by copyright.  Please see the usage policy.