We’re going to start by reading the tutorials for each of the components separately, then we are going to combine them to make our reverse geocache box.
- Ultimate GPS Tutorial:http://learn.adafruit.com/adafruit-ultimate-gps
- Character LCD: http://learn.adafruit.com/character-lcds/
- Servo: http://www.arduino.cc/en/Reference/Servo - It’s pretty simple. You just tell it what angle you want the servo to go to, and it obliges.
Now that you’ve read how the LCD, GPS, and servo work, let’s combine them. The serial Library uses digital pins 0 and 1, so we want to stay away from those. This allows us to debug the Ardunio with Serial.print() and see what’s going on in the program. The GPS breakout uses digital pins 2 and 3, just like in the Ultimate GPS tutorial. The LCD uses 6 pins, and the Servo motor uses 1 pin.
I put the Servo on Pin 9, and I put the LCD in pins 7,8,6,10,11,and 12 (I had to move the third LCD pin from pin 9 to pin 6 to accommodate the servo).
NOTE: The Servo library and the SoftwareSerial library (which the GPS uses to spit out data) do NOT play nice with each other. To fix this, we’re going to install an older version of the servo library that doesn’t interfere with SofwareSerial.
That library is located here: http://arduiniana.org/libraries/pwmservo/
Download version 2 (by Paul Stoffregen) and install it into the libraries folder in your Arduino folder, just like you did with the Adafruit_GPS folder in the Ultimate GPS tutorial. This library is called PWMServo. It requires the servo to be on Pin 9 or 10 (which is why you see the change above). Otherwise, you interface with it similarly, you just have to use servoLatch.attach(SERVO_PIN_A); when you attach the servo pin.
Now, lay out all of your components. I tried to make the total size as small as possible, and fit into the 5” x 5” box I made. You can see my layout below. The Uno is on the bottom, with two wires coming off to power my proto board. The LCD does not use pins 7, 8, 9, or 10, so I chose to put the contrast potentiometer there. I cut the traces to those pins so I didn’t advertently send a signal to the LCD.
NOTE: If you’re using the perma-proto board, you’ll notice that the digital pins on the Uno are not spaced correctly between pins 7 and 8. There is a .160” gap between the pins. I got around this by bending pins 8-12 to fit. If I did this again, I would have used the proto shield, which accounts for this gap and makes it super easy to connect to the Uno.