Skip to content

Commit

Permalink
Starting on the randomization game feaure - on a fixed display schedu…
Browse files Browse the repository at this point in the history
…le for now, will test for consistancy before implementing long-term sleeps
  • Loading branch information
kylehotchkiss committed Jun 2, 2013
1 parent 1507aae commit 6191668
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
29 changes: 2 additions & 27 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
## Waypoints Game (for Arduino)

A few years back, I read a story about a guy who made this box. On the outside of this box, there was a screen and a button. When the button was pressed, the screen showed a distance in Miles. There was no direction.
A GPS-based Driving game built on Arduino

This same guy took his girlfriend out one day, with the box. He made a rule for the box - you could only have 10 button pushes. He choose a special spot for them both, and they took off. They found that the trick is to draw a circle on the map that matches the given distance around your current location. With enough circles, they made it to their waypoint. The box unlocked, and inside was a ring. Engagement, huzzah!

I wanted to make the same thing since I'm becoming gifted with dealing with GPS and coordinate based systems. I wanted the experience and more importantly I want to play this game with my friends soon. No engagement rings, or even unlocking functionality here - my game would involve a prize buried at a location!

This code represents the beginning of that game. I'm currently brainstorming some dynamic rules for it (like the Arduino showing the distance for 10s every random amount of minutes underneath 20 minutes).

## Getting Started
Like most Arduino projects, this is not going to be a complete solution for you and your hardware, unless you copycat my setup. I choose an older [Arduino UNO SMD edition](https://www.sparkfun.com/products/10356), an [EM-406A GPS Module](https://www.sparkfun.com/products/465), and a [Parallax LCD Screen](http://www.parallax.com/tabid/768/productid/50/default.aspx) (With Backlight).

You'll need to hook these all up and have them working independently prior to dropping in the code. When you have the components working, change some of the variables in the top of the INO accordingly. Then turn it on and TADA, Waypoints Game!

## Technical
This project thought me a good chunk about how to handle multiple serial devices with Arduino. For the GPS, I use the hardware UART because of it's reliability, and for the LCD I used SoftwareSerial. The GPS was returning a ton of garbage data for me at first, so I tried writing the implementation in lower C (meaning *less* Strings, not *no* Strings) and now it works absolutely wonderful!

If you choose the same GPS module as me (which I recommend, it's a workhorse of a module), I recommend running this bit of code before you jump off:

Serial.write("$PSRF103,01,00,00,01*25\r\n");
Serial.write("$PSRF103,02,00,00,01*26\r\n");
Serial.write("$PSRF103,03,00,00,01*27\r\n");
Serial.write("$PSRF103,04,00,00,01*20\r\n");
Serial.write("$PSRF103,05,00,00,01*21\r\n");

That will disable all the GPS messages other than the GPGGA sentence, which contains all the data we need.

## It doesn't work!
This project was made for my pleasure and wasn't created with dynamic use cases in mind. Therefore, some things may be static for my setup (I think my altitude code may break things) and need your own craftiness to mend. Just fork and [tweet at me](http://twitter.com/kylehotchkiss) if you change some things to make it work better for you - I'd love to hear your milage!
[Check out the Project Page for project details and for the gameplay details!](http://kylehotchkiss.com/blog/waypoints/)
28 changes: 24 additions & 4 deletions waypoints.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@
*/

#define _USE_MATH_DEFINES

#include <SoftwareSerial.h>



////////////////////////////////////
// What Matters to you - Settings //
////////////////////////////////////
const int lcd_pin = 3;

// Where to?
const double waypoint_lat = 37.7070794;
const double waypoint_lon = -79.2889216;

// Assumed average speed in MPH (Randomization indexer)
const int avgSpeed = 30;


///////////////////
// LCD Constants //
///////////////////
const int lcd_pin = 3;

// ASCII control codes
const int lcd_clear = 12;
const int lcd_lightOn = 17;
const int lcd_lightOff = 18;
Expand Down Expand Up @@ -185,14 +191,28 @@ void loop() {
}
}

///////////////////////////////////////////
// GPS-Lock Confirmed | Engagement Layer //
///////////////////////////////////////////
if ( latitude != 0 && longitude != 0 ) {
lcd.write(212);
lcd.write(220);
delay(5);
lcd.write( lcd_lightOn );
delay(5);
lcd.write( lcd_clear );
delay(5);
lcd.print("Distance:\r");
lcd.print( distance( latitude, longitude, waypoint_lat, waypoint_lon ));
lcd.print( distance( latitude, longitude, waypoint_lat, waypoint_lon ), 4);
lcd.print( "km" );

delay( 5000 );

lcd.write( lcd_clear );
delay(5);
lcd.write( lcd_lightOff );

delay( 20000 );
}
}

Expand Down

0 comments on commit 6191668

Please sign in to comment.