sleepTime = 120 * 60 * 1000;
}
try
{
Thread.sleep(sleepTime);
}
catch(InterruptedException ignoreMe) {}
}
}
}
void
tweetAlarm() {
ConfigurationBuilder cb =
cb.setDebugEnabled(true)
.setOAuthConsumerKey(API_KEY)
.setOAuthConsumerSecret(API_SECRET)
.setOAuthAccessToken(ACCESS_TOKEN)
.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);
TwitterFactory tf =
Twitter twitter = tf.getInstance();
try
{
Status status = twitter.updateStatus(
"Someone, please, take me to the beach!"
);
println(
"Successfully updated status to '"
);
}
catch
(TwitterException e) {
e.printStackTrace();
}
}
Whenever new data arrives on the serial port, the Processing runtime environ-
ment calls the
serialEvent
we check whether it contains a decimal number followed by a blank and a C
or an F character. This ensures we ve read an actual temperature data set
and not some digital garbage.
If we got a syntactically correct temperature data set, we convert it into a
object and check to see whether it s greater than
should be forced to work at temperatures that high!) If yes, we call
and Tweet a message to encourage some followers to rescue us. Then we wait
for two hours until our next check. Otherwise, we wait five minutes and check
the temperature again.
tweetAlarm
updates our Twitter status and is simple. In good old Java tradition,
we create a new
Twitter
ConfigurationBuilder
object that we have initialized with our Twitter application
new
ConfigurationBuilder();
new
TwitterFactory(cb.build());
+ status.getText() +
method. There we try to read a line of text, and then
instance using a
TwitterFactory
www.it-ebooks.info
Tweeting Messages with Processing
"'."
MAX_WORKING_TEMP
. (No one
tweetAlarm
. The factory expects a
171
float
report erratum
discuss
Need help?
Do you have a question about the Arduino Uno and is the answer not in the manual?