Hardware Reference
In-Depth Information
Insert the SD card into your computer and create a new TXT file called speed
.txt on the SD card. In this file, simply enter the refresh time in milliseconds that
you want to use. In FigureĀ 13-16, you can see that I set it to 1000ms, or 1 second.
Figure 13-16: Creating the speed command file
After choosing a desired refresh speed, save the file on the SD card and put
it back in your Arduino shield. You now modify your program to read this file,
extract the desired field, and use it to set the refresh speed for data logging.
To open a file for reading, you use the same SD.open command that you used
earlier, but you do not have to specify the FILE_WRITE parameter. Because the
File class that you are using inherits from the stream class (just like the Serial
class), you can use many of the same useful commands, such as parseInt() ,
that you've used in previous chapters. To open and read the update speed from
the file, all you have to do is this:
File commandFile = SD.open("speed.txt");
if (commandFile)
{
Serial.println("Reading Command File");
Search WWH ::




Custom Search