Hardware Reference
In-Depth Information
if ( fp == NULL ) {
Serial . println ( "Couldn't run the curl command." );
return - 1 ;
}
else {
fgets ( output , sizeof ( output ), fp );
}
if ( pclose ( fp ) != 0 ) {
Serial . println ( "The curl command returned an error." );
return - 1 ;
}
return atoi ( output );
}
Include the code from Arduino's Liquid Crystal library.
Create a new object called lcd and specify which Galileo pins are
connected to it.
Initialize the LCD using the pin numbers from before. Thanks to
Github user houmei for this hint: https://gist.github.com/houmei/
8505883 . This is only needed with the Galileo and isn't needed for a
regular Arduino.
Specify that the LCD has two lines of 16 characters each.
Set the cursor to the fourth character on the first line. (Start counting
from 0.)
Print the message “days until”.
Reposition the cursor to the first character on the second line. (Again,
counting from 0.)
Reset the cursor to the beginning of the first line.
Clear out anything that's there by printing three spaces.
Reset the cursor to the beginning of the first line again.
Print the response from our Python script, which parses the JSON
response from the server.
Wait 30 minutes before refreshing the display.
After uploading the code, the message should appear in the LCD display! You
might need to adjust the display's contrast using the potentiometer. It should
look something like Figure 6-3 .
Search WWH ::




Custom Search