Hardware Reference
In-Depth Information
There are also global variables
to keep track of the tweeter,
the tweet, when you last made an
HTTP request, and how long to delay
between requests.
8
Continued from opposite page.
String twitterHandle = ""; // the tweeter
String tweet = ""; // the tweet
int tweetBufferLength; // the space to reserve for the tweet
int tweetLength = 0; // the actual length of the tweet
Finally, there are global variables for
the various characteristics of the LCD
display and constants for the scroll-
delay potentiometer.
long lastRequestTime = 0; // last time you connected to the server
int requestDelay = 15 * 1000; // time between HTTP requests
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(9,8, 7, 6,5, 3);
const int screenWidth = 16; // width of the LCD in characters
long lastScrollTime = 0; // last time you scrolled the LCD
int scrollDelay = 130; // delay between LCD moves
int cursorPosition = 0; // cursor position on the LCD
const int potVoltage = A0; // voltage for the scroll delay pot
const int potGround = A2; // ground for the scroll delay pot
const int potInput = A1; // scroll delay pot
setup() initializes communications:
serial, Ethernet, communications
to the RFID reader via I2C, and the
LCD. It also sets A0 high as a digital
output, and A2 low, to supply voltage
and ground for the scroll-delay poten-
tiometer.
8
void setup() {
// initialize serial communications and the reader:
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println(F("Failed to configure Ethernet using DHCP"));
Ethernet.begin(mac, ip);
}
// set pins A0 and A2 to digital out, and use them as
// power and ground for the scroll speed potentiometer:
pinMode(potGround, OUTPUT);
pinMode(potVoltage, OUTPUT);
digitalWrite(potGround, LOW);
digitalWrite(potVoltage, HIGH);
// reserve 140 * 2 screenWidths + 3 bytes extra for tweet:
tweetBufferLength = 140 + 2*screenWidth + 3;
tweet.reserve(tweetBufferLength);
Rfid.begin();
// set up the LCD's number of columns and rows:
lcd.begin(screenWidth,2);
lcd.clear();
lcd.print(F("Ready"));
}
 
Search WWH ::




Custom Search