Twitter: Arduino without ETHER shield. PLEASE HELP ME GUYS :'(
in
Integration and Hardware
•
1 year ago
Okay basically I need to learn how to tweet on twitter without using the arduino ethernet shield. YES my arduino is connected to the computer. I am very new to processing and the reading code on processing is very hard to understand.
So basically my arduino fires values from my sensor and there's an if statement that says,
if the value>15, "we have a problem"
I want to learn how can I tweet this directly from my arduino to twitter using processing.
I've been researching for weeks now, and a lot of the code which i've managed to compile, but they all open with small windows and but no tweeets on twitter are coming.
An example of this is the code below that I found on
http://www.instructables.com/id/Touch-Me-NotWithout-Ethernet-Sheild/
I tried to test the code below with my orignal program on arduino. The twitter code on processing worked saying COLOUR SELECTED: 15.96. BUT NO TWITTER TWEET.
Then i tired to test it with a simple program on the arduino. When I complied the twitter code on processing, it says color selected is NULL. NO TWEET ON MY TWITTER
ARDUINO CODE:----------------------------------------------------------------------------------
void setup(){
// initialize seria
Serial.begin(9600);
Serial.println("Yes it works");
}
void loop(){
}
// initialize seria
Serial.begin(9600);
Serial.println("Yes it works");
}
void loop(){
}
PROCESSING CODE:-------------------------------------------------------------------------------------------------
/*************
* based on: http://processing.org/reference/libraries/serial/serialEvent_.html
*************/
import processing.serial.*;
Serial myPort; // The serial port
PFont myFont; // The display font
String inString; // Input string from serial port
int lf = 10; // ASCII linefeed
Twitter twitter; // Twitter
//Going to get oAuth working instead of this, but this will do for now
String username = "YOUR-TWITTER-USERNAME"; // you Twitter Username Here
String password = "YOUR-TWITTER-PASSWORD"; // your Twitter Password Here
void setup() {
size(400,200);
twitter = new Twitter(username,password);
myFont = loadFont("AppleGothic-48.vlw");
textFont(myFont, 18);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(lf); //wiat for line feed to specify end of serial buffer
}
void draw() {
background(100);
text("color selected: " + inString, 10,50);
}
void serialEvent(Serial p) {
inString = p.readString();//read serial string
//For some reason this only wanted to work in a try catch
try
{
Status status1 = twitter.updateStatus("Arduino's favorite color is "+inString);//update twitter status
}
catch( TwitterException e) {
println(e.getStatusCode());
}
}
Make sure you change USERNAME and PASSWORD with your twitter accounts username and password.
Make sure that you only use serial.println command on whatever you want to post on twitter.
* based on: http://processing.org/reference/libraries/serial/serialEvent_.html
*************/
import processing.serial.*;
Serial myPort; // The serial port
PFont myFont; // The display font
String inString; // Input string from serial port
int lf = 10; // ASCII linefeed
Twitter twitter; // Twitter
//Going to get oAuth working instead of this, but this will do for now
String username = "YOUR-TWITTER-USERNAME"; // you Twitter Username Here
String password = "YOUR-TWITTER-PASSWORD"; // your Twitter Password Here
void setup() {
size(400,200);
twitter = new Twitter(username,password);
myFont = loadFont("AppleGothic-48.vlw");
textFont(myFont, 18);
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(lf); //wiat for line feed to specify end of serial buffer
}
void draw() {
background(100);
text("color selected: " + inString, 10,50);
}
void serialEvent(Serial p) {
inString = p.readString();//read serial string
//For some reason this only wanted to work in a try catch
try
{
Status status1 = twitter.updateStatus("Arduino's favorite color is "+inString);//update twitter status
}
catch( TwitterException e) {
println(e.getStatusCode());
}
}
Make sure you change USERNAME and PASSWORD with your twitter accounts username and password.
Make sure that you only use serial.println command on whatever you want to post on twitter.
1