To collect data, we need to find a way to move data from the Arduino to your computer. It turns out the Arduino's memory is too small to hold much data, so collecting the data and sending it after an experiment is over is not an option. The data has to be sent in real time, as it is generated. We use the USB connection to do this, which is simulating a serial link to your computer. So our programs just print out data, which sends it over the USB link. To do this we need to use a high baud rate (2000000). This is also the baud rate we set in all the Arduino programs with
Serial.begin( 2000000 );The Bluetooth link is too slow. We could use the WiFi link to move data wirelessly, but I haven't tried this. Unfortunately, the Arduino IDE does not provide a way to save what is printed out. We can run a terminal emulator that can capture (log) whatever is sent from the Arduino. I use Putty, as it is a popular terminal emulator that runs on Linux, Windows, and Macs. There are many other terminal emulators that run on Windows, so if you are already familiar with one that can log the Arduino output, use that.
You can type commands to the Arduino by typing into the Putty window.
In a perfect world, whenever you started Putty, the Arduino would reboot
and you would be capturing its output. You would be able to download new
programs using the Arduino IDE. This did not work on my
Linux boxes. I had to have no Putty running while downloading a program
using the Arduino IDE, kill any running Arduino IDEs,
and then start Putty to capture output.
I had to then kill the Putty in order to download a new program, and then
restart Putty. Sometimes I had to press the reset button on the Arduino
Nano
(white button near the USB connector on the Arduino itself (hard to reach),
or the button near the back of the
board near the rows of red, black, and yellow pins (easy to reach))
or
power cycle the Arduino (remove USB cable
from laptop and turn the battery off,
and then re-plug in the USB cable and turn
the battery back on) to get the Arduino to reboot and show a prompt when
putty is started up again. You don't need to do this if you don't need to
see what the Arduino initially prints out.
Let's collect some data using the steps or sinusoids program. First put the robot upside down, so the robot doesn't actually go anywhere, the wheels just spin in the air.
Make sure your battery is fully charged. Connect the USB cable between the Arduino Nano and your computer.
Preload steps or sinusoids using the Arduino IDE. Then kill the Arduino IDE.
Run putty and type a g into that window. Watch the pretty characters whiz by.
Press the reset button on the rear end of the controller board
next to the rows of red, black, and yellow pins to reboot the Arduino and kill putty.
Notice the putty.log file in the directory you ran putty in.