Hardware Reference
In-Depth Information
When all the code is complete for the Arduino sketch, compile and upload it to the Arduino Mega ADK with the
SD adapter and the XBee module connected. The openFrameworks program needs to be started to ensure that the
WaitForReply function calls are uncommented and the program is recompiled. Insert an SD card into the Arduino
and power on the setup. When the Arduino is powered on, the openFrameworks program should start to send data
and move through the data arrays. The serial monitor can be used to see the data being written to the SD card after
three sensors have be sent and received.
Now that the data is being logged to the SD card, the ADK monitor program that was created in Chapter 4 can be
used to verify that the data is getting sent to the Android device. While the Arduino and openFrameworks are running,
plug the Android device into the host side of the Mega ADK and wait till the Android program detects the event.
A command can be sent to the Mega ADK when an a is sent; in this case the log data should be printed to the Android
screen. The data should match the printed data on the Arduino serial monitor and should update at about the same
time while connected.
Before the Android program is complete, you can verify the data on the SD card by using a hex editor to read
the sensor.log file when the SD card is read by a computer.
Note
The Android Application
In this section, we'll make the Android program display the data in a more human-readable format. The example
adds a chart that graphs the data in a fashion similar to the openFrameworks code. The layout of the program is
shown in Figure 8-3 . The graph is drawn at the top of the screen above the monitor box. Making the graph is a bit
difficult to do from scratch, so a library is used to add the functionality. The library that is going to be used is called
AChartEngine . The chart library adds the ability to make scatter plots, pie charts, and line or bar graphs that can be
created dynamically and can be pinched, zoomed, and scrolled. The binary distribution of the library needs to be
downloaded from www.achartengine.org .
 
 
Search WWH ::




Custom Search