EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #188 background imageLoading...
Page #188 background image
sleepTime = 120 * 60 * 1000;
}
try {
Thread.sleep(sleepTime);
}
catch(InterruptedException ignoreMe) {}
}
}
}
void tweetAlarm() {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(API_KEY)
.setOAuthConsumerSecret(API_SECRET)
.setOAuthAccessToken(ACCESS_TOKEN)
.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
try {
Status status = twitter.updateStatus(
"Someone, please, take me to the beach!"
);
println(
"Successfully updated status to '" + status.getText() + "'."
);
}
catch (TwitterException e) {
e.printStackTrace();
}
}
Whenever new data arrives on the serial port, the Processing runtime environ-
ment calls the
serialEvent
method. There we try to read a line of text, and then
we check whether it contains a decimal number followed by a blank and a C
or an F character. This ensures weve 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
float
object and check to see whether its greater than
MAX_WORKING_TEMP
. (No one
should be forced to work at temperatures that high!) If yes, we call
tweetAlarm
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
instance using a
TwitterFactory
. The factory expects a
ConfigurationBuilder
object that we have initialized with our Twitter application
report erratum discuss
Tweeting Messages with Processing 171
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino Pro Mini and is the answer not in the manual?

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals