loading
Arduino Processing Twitter
Post a tweet when your sensor changes states, using Arduino, Processing, and twitter4j.
Note: I've got a Python version of this project here: https://www.instructables.com/id/simpleTweet01python/

In the video you'll see two lines appear. They look like this:
new tweet --:{ Opened door at 14:21:57}:--
new tweet --:{ Closed door at 14:22:1}:--

These confirm that new messages were sent to Twitter when the switch opened and closed.
Visit twitter.com/msg_box to see the timeline.

Step 1: Concept

The idea for this project was to develop generic code allowing you to automatically generate tweets based on input to your Arduino. This example uses a magnetic reed switch, which is your basic on / off switch. You can use this code as is for any two-state switch or modify it for more diversity.

We attach the magnetic reed sensor to my office door and door-frame. A wire runs from the magReed sensor to a pin in the Arduino circuit. Arduino watches that pin's status, HIGH or LOW, and when the status changes from one to the other Arduino reports on that change through Serial.write(). The Processing sketch picks up the Serial.write() call and checks to see if the current state is the same as the last one posted to Twitter. If the two states are the same then it will not post, but if the new state is different from the previous state, then we're in business.

Processing uses twitter4j and OAuth to post the new state to your Twitter account. Done and done.

Step 2: Arduino

// simpleTweet_00_a

/*
 simpleTweet_00 arduino sketch (for use with
 simpleTweet_00 processing sketch) by @msg_box june2011

 This script is intended for use with a magnetic reed switch,
but any on/off switch plugged into pin #10 will readily work.

The Arduino is connected to a circuit with a sensor that
triggers the code: Serial.write(n); where n = 1 or 2.
The Processing sketch listens for that message and then
uses the twitter4j library to connect to Twitter
via OAuth and post a tweet.

To learn more about arduino, processing, twitter4j,
OAuth, and registering your app with Twitter...
visit <https://www.instructables.com/id/Simple-Tweet-Arduino-Processing-Twitter/>
visit <http://www.twitter.com/msg_box>

This code was made possible and improved upon with
help from people across the internet. Thank You.
Special shoutouts to the helpful lurkers at twitter4j,
arduino, processing, and bloggers everywhere, and
to the adafruit & ladydada crowdsource.
And above all, to my lovely wife, without
whom, none of this would have been possible.

Don't be a dick.
*/

const int magReed_pin = 10; // pin number
int magReed_val = 0;
int currentDoorState = 1; // begin w/ circuit open
int previousDoorState = 1;

void setup(){
Serial.begin(9600);
pinMode(magReed_pin, INPUT);
}

void loop(){
watchTheDoor();
}

void watchTheDoor(){
magReed_val = digitalRead(magReed_pin);
if (magReed_val == LOW){ // open
currentDoorState = 1;
}
if (magReed_val == HIGH){ // closed
currentDoorState = 2;
}
compareStates(currentDoorState);
}

void compareStates(int i){
if (previousDoorState != i){
previousDoorState = i;
Serial.write(i);
delay(1000); //
}
}
 

Step 3: Processing

Install twitter4j 

You'll need to install the twitter4j library so it can be used by Processing.
Get it here: http://twitter4j.org/en/index.html#download
Install it here (or equivalent): C:\Program Files\processing-1.5.1\modes\java\libraries
You're done.
Access it here: Processing > Sketch > Import Library... > twitter4j
And when you do, it'll add this to the top of your code:
import twitter4j.conf.*;
import twitter4j.internal.async.*;
import twitter4j.internal.org.json.*;
import twitter4j.internal.logging.*;
import twitter4j.http.*;
import twitter4j.api.*;
import twitter4j.util.*;
import twitter4j.internal.http.*;
import twitter4j.*;
Incidentally, you'll also add Serial I/O from the Sketch > Library, but that's not important right now.

So why do you need twitter4j? The short answer is that it provides you with simple functionality so you don't have to write a whole bunch of crazy code every time you want to access Twitter. We use twitter4j because it's awesome and it makes our job easier. 

// #####################################################################
// #####################################################################

// simpleTweet_00_p

/*
 simpleTweet_00 processing sketch (for use with
 simpleTweet_00 arduino sketch) by @msg_box june2011

 The Arduino is connected to a circuit with a sensor that
triggers the code: Serial.write(n); where n = 1 or 2.
The Processing sketch listens for that message and then
uses the twitter4j library to connect to Twitter
via OAuth and post a tweet.

compareMsg() is added in case you want to compare
the current and previous tweets to prevent retweets.

This Processing code requires the twitter4j library
and your registered app info from dev.twitter.com

To learn more about arduino, processing, twitter4j,
OAuth, and registering your app with Twitter...
visit <https://www.instructables.com/id/Simple-Tweet-Arduino-Processing-Twitter/>
visit <http://www.twitter.com/msg_box>

This code was made possible and improved upon with
help from people across the internet. Thank You.
Special shoutouts to the helpful lurkers at twitter4j,
arduino, processing, and bloggers everywhere, and
to the adafruit & ladydada crowdsource.
And above all, to my lovely wife, without
whom, none of this would have been possible.

Don't be a dick.
*/

import processing.serial.*;

import twitter4j.conf.*;
import twitter4j.internal.async.*;
import twitter4j.internal.org.json.*;
import twitter4j.internal.logging.*;
import twitter4j.http.*;
import twitter4j.api.*;
import twitter4j.util.*;
import twitter4j.internal.http.*;
import twitter4j.*;

static String OAuthConsumerKey = "YOUR CONSUMER KEY";
static String OAuthConsumerSecret = "YOUR CONSUMER SECRET";
static String AccessToken = "YOUR ACCESS TOKEN";
static String AccessTokenSecret = "YOUR ACCESS TOKEN SECRET";

Serial arduino;
Twitter twitter = new TwitterFactory().getInstance();

void setup() {
size(125, 125);
frameRate(10);
background(0);
println(Serial.list());
String arduinoPort = Serial.list()[0];
arduino = new Serial(this, arduinoPort, 9600);
loginTwitter();
}

void loginTwitter() {
twitter.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret);
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);
}

private static AccessToken loadAccessToken() {
return new AccessToken(AccessToken, AccessTokenSecret);
}

void draw() {
background(0);
text("simpleTweet_00", 18, 45);
text("@msg_box", 30, 70);
listenToArduino();
}

void listenToArduino() {
String msgOut = "";
int arduinoMsg = 0;
if (arduino.available() >= 1) {
arduinoMsg = arduino.read();
if (arduinoMsg == 1) {
msgOut = "Opened door at "+hour()+":"+minute()+":"+second();
}
if (arduinoMsg == 2) {
msgOut = "Closed door at "+hour()+":"+minute()+":"+second();
}
compareMsg(msgOut); // this step is optional
// postMsg(msgOut);
}
}

void postMsg(String s) {
try {
Status status = twitter.updateStatus(s);
println("new tweet --:{ " + status.getText() + " }:--");
}
catch(TwitterException e) {
println("Status Error: " + e + "; statusCode: " + e.getStatusCode());
}
}

void compareMsg(String s) {
// compare new msg against latest tweet to avoid reTweets
java.util.List statuses = null;
String prevMsg = "";
String newMsg = s;
try {
statuses = twitter.getUserTimeline();
}
catch(TwitterException e) {
println("Timeline Error: " + e + "; statusCode: " + e.getStatusCode());
}
Status status = (Status)statuses.get(0);
prevMsg = status.getText();
String[] p = splitTokens(prevMsg);
String[] n = splitTokens(newMsg);
//println("("+p[0]+") -> "+n[0]); // debug
if (p[0].equals(n[0]) == false) {
postMsg(newMsg); 
}
//println(s); // debug
}
 

Step 4: Twitter

To post a tweet, do the following:

* Install twitter4j  http://twitter4j.org/en/index.html#download
* (Update: I've attached "twitter4j.jar" to this instructable page.)
* Create a Twitter account  twitter.com
* Register an application with Twitter   https://dev.twitter.com/apps/new

Install twitter4j

You'll need to install the twitter4j library so it can be used by Processing.
Get it here: http://twitter4j.org/en/index.html#download  
Install it here (or equivalent): C:\Program Files\processing-1.5.1\modes\java\libraries
You're done.
Access it here: Processing > Sketch > Import Library... > twitter4j
And when you do, it'll add this to the top of your code:
import twitter4j.conf.*;
import twitter4j.internal.async.*;
import twitter4j.internal.org.json.*;
import twitter4j.internal.logging.*;
import twitter4j.http.*;
import twitter4j.api.*;
import twitter4j.util.*;
import twitter4j.internal.http.*;
import twitter4j.*;

Incidentally, you'll also add Serial I/O from the Sketch > Library, but that's not important right now.

So why do you need twitter4j? The short answer is that it provides you with simple functionality so you don't have to write a whole bunch of crazy code every time you want to access Twitter. We use twitter4j because it's awesome and it makes our job easier.

Create a Twitter account

You've probably already got one (or twelve) but for the absolute noob, take heart. It's easy.
Goto twitter.com and set up an account. Make it a public account, that way if you ever want your friends to look at it they don't have to go through a whole bunch of hooey to get there. And don't post personal stuff like "Out of town, leaving diamonds on back porch." 

You'll see people using the "@" and "#" symbols a lot. Put @ before a username and # before a concept. For example, if you post the following tweet "I enjoyed the @msg_box simpleTweet_00 on @instructables #goodtimes" then that tweet will get sent to my feed (and to instructables's feed too) and it'll get added to a cache of all posts that have ever used the phrase "#goodtimes." There's more, but it's not within the scope of this lesson. Play with it. You'll figure it out.

Register an application with Twitter

What does that even mean? Relax. Think of it this way:  you're creating a set of special high-tech usernames and passwords so the stuff you make can access Twitter. It's like Twitter is this big castle with a front door for all the human guests and a back door for all the automated service personnel. These high-tech usernames and passwords are called OAuth. OAuth lets your device access Twitter through the service entrance.

Having already created my Twitter account @msg_box I then went here https://dev.twitter.com/apps/new to get my OAuth password info. Review the three attached images of the forms .

First Page: Make sure you check "Client " and not "Browser", and that you allow "Read & Write ."
Second Page: Here's where you find your CONSUMER KEY and your CONSUMER SECRET
Third Page: Here's where you find your ACCESS TOKEN and your ACCESS TOKEN SECRET

You will need this information when your program logs into Twitter (via the service entrance.) In the Processing script simpleTweet_00_p you will enter this information in here:
static String OAuthConsumerKey = "YOUR CONSUMER KEY";
static String OAuthConsumerSecret = "YOUR CONSUMER SECRET";
static String AccessToken = "YOUR ACCESS TOKEN";
static String AccessTokenSecret = "YOUR ACCESS TOKEN SECRET";


That's it. Not hard at all.


Step 5: Circuit Board


Breadboard vs Circuit Board  
The fasted way to hack this project together is with a breadboard (image). The breadboard, or solderless breadboard, is perfect for prototyping, for proving that your circuit works as you expect it to. That's because the breadboard allows you to attach and disconnect wires without any forethought or commitment or difficulty. With a breadboard, if your circuit does not perform the way you thought it would, then you can take it apart and reassemble it as many times as you like until you've got it right. After you've proven the concept and you know your circuit is right, then it's a good idea to solder together a real circuit board. I'm a big fan of soldering your own circuit boards. It's fun and easy and adds a special element of ownership to a project. If you want to reproduce lots of copies of your circuit, then you should consider printed circuits. Printed Circuits are the next step after Circuit Boards and are a great way to share your project with others, especially when it's a complicated circuit. You can order printed circuits or make them on your own. 

Step 6: In Conclusion....

The idea for this project was to develop generic code allowing you to automatically generate tweets based on input to your Arduino. With this code you now have the foundation for a tweeting empire. This project was simple and fun, but imho it's not a hack, it's a make. 

I did not bust anything open, like a door alarm and piggyback on it's systems. That'd be a hack. Instead I built a clean prototype, I made it. And I had fun. I'll look for something to hack and be back with more good fun. 

Cheers!

<p>i love the colors and the shadows</p>
Thank you so much, worked perfectly! really awesome. <br>
hey,suppose i have a processing or python application running ,so how can I let the user share with his friends that he is using my application by tweeting on his timeline and another thing I wanted to ask does Facebook has such api. <br>By the way great work ,helped a lot...!!!
Thank for your good info. <br> <br>I tried this project. <br> <br>But Only works at just 1st time to my iphone twitter app. <br> <br>and then never works again --; <br> <br>My error message is here: <br>------------------------------------------------------------------ <br>RXTX Warning: Removing stale lock file. /var/lock/LK.027.033.008 <br> <br>What's wrong with me ? <br> <br>Intel iMac x64, MacOSX 10.8.3 <br>Arduino 1.5.1 <br>Processing 2.0b8 <br>Twitter4j.jar that you offering one. <br> <br> <br> <br>
Hi everyone, I found a solution to all your problems. I'll post soon! ;)
hey man, great tut but I am totally stuck now. Done evrything from making the twitter dev and installed all the packages (i hope I done that right). <br>But i am currently getting these errors on processing: <br>Stable Library <br>========================================= <br>Native lib Version = RXTX-2.1-7 <br>Java lib Version = RXTX-2.1-7 <br>[0] &quot;COM5&quot; <br>[1] &quot;COM7&quot; <br>[2] &quot;COM8&quot; <br>gnu.io.PortInUseException: Unknown Application <br> at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354) <br> at processing.serial.Serial.(Unknown Source) <br> at processing.serial.Serial.(Unknown Source) <br> at simpleTweet_00_p.setup(simpleTweet_00_p.java:91) <br> at processing.core.PApplet.handleDraw(Unknown Source) <br> at processing.core.PApplet.run(Unknown Source) <br> at java.lang.Thread.run(Thread.java:662) <br>Exception in thread &quot;Animation Thread&quot; java.lang.RuntimeException: Error inside Serial.() <br> at processing.serial.Serial.errorMessage(Unknown Source) <br> at processing.serial.Serial.(Unknown Source) <br> at processing.serial.Serial.(Unknown Source) <br> at simpleTweet_00_p.setup(simpleTweet_00_p.java:91) <br> at processing.core.PApplet.handleDraw(Unknown Source) <br> at processing.core.PApplet.run(Unknown Source) <br> at java.lang.Thread.run(Thread.java:662) <br> <br>[color=red]This is my current processing code:[/color] <br> <br>import processing.serial.*; <br> <br>import twitter4j.conf.*; <br>import twitter4j.internal.async.*; <br>import twitter4j.internal.org.json.*; <br>import twitter4j.internal.logging.*; <br>import twitter4j.http.*; <br>import twitter4j.api.*; <br>import twitter4j.util.*; <br>import twitter4j.internal.http.*; <br>import twitter4j.*; <br> <br>static String OAuthConsumerKey = &quot;ykaw70kvBc6jVV21eLlWA&quot;; <br>static String OAuthConsumerSecret = &quot;PllQqnwaZV7aYuH33vniloGW2U5fbkfYxef2LQVAK0&quot;; <br>static String AccessToken = &quot;20026567-9juOyYchv9k7PXsu7kyrvhpHKkOY3Fg6xTn9vatuA&quot;; <br>static String AccessTokenSecret = &quot;AcIhlVX95nvpFYMyk9oh41PWHe3TXYqhMbSy6hLgQ&quot;; <br> <br>Serial arduino; <br>Twitter twitter = new TwitterFactory().getInstance(); <br> <br>void setup() { <br> size(125, 125); <br> frameRate(10); <br> background(0); <br> println(Serial.list()); <br> String arduinoPort = Serial.list()[0]; <br> arduino = new Serial(this, arduinoPort, 9600); [color=red]ERROR BEGINS ON THIS LINE[/color] <br> loginTwitter(); <br>} <br> <br>void loginTwitter() { <br> twitter.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret); <br> AccessToken accessToken = loadAccessToken(); <br> twitter.setOAuthAccessToken(accessToken); <br>} <br> <br>private static AccessToken loadAccessToken() { <br> return new AccessToken(AccessToken, AccessTokenSecret); <br>} <br> <br>void draw() { <br> background(0); <br> text(&quot;simpleTweet_00&quot;, 18, 45); <br> text(&quot;@msg_box&quot;, 30, 70); <br> listenToArduino(); <br>} <br> <br>void listenToArduino() { <br> String msgOut = &quot;&quot;; <br> int arduinoMsg = 0; <br> if (arduino.available() &gt;= 1) { <br> arduinoMsg = arduino.read(); <br> if (arduinoMsg == 1) { <br> msgOut = &quot;Opened door at &quot;+hour()+&quot;:&quot;+minute()+&quot;:&quot;+second(); <br> } <br> if (arduinoMsg == 2) { <br> msgOut = &quot;Closed door at &quot;+hour()+&quot;:&quot;+minute()+&quot;:&quot;+second(); <br> } <br> compareMsg(msgOut); // this step is optional <br> // postMsg(msgOut); <br> } <br>} <br> <br>void postMsg(String s) { <br> try { <br> Status status = twitter.updateStatus(s); <br> println(&quot;new tweet --:{ &quot; + status.getText() + &quot; }:--&quot;); <br> } <br> catch(TwitterException e) { <br> println(&quot;Status Error: &quot; + e + &quot;; statusCode: &quot; + e.getStatusCode()); <br> } <br>} <br> <br>void compareMsg(String s) { <br> // compare new msg against latest tweet to avoid reTweets <br> java.util.List statuses = null; <br> String prevMsg = &quot;&quot;; <br> String newMsg = s; <br> try { <br> statuses = twitter.getUserTimeline(); <br> } <br> catch(TwitterException e) { <br> println(&quot;Timeline Error: &quot; + e + &quot;; statusCode: &quot; + e.getStatusCode()); <br> } <br> Status status = (Status)statuses.get(0); <br> prevMsg = status.getText(); <br> String[] p = splitTokens(prevMsg); <br> String[] n = splitTokens(newMsg); <br> //println(&quot;(&quot;+p[0]+&quot;) -&gt; &quot;+n[0]); // debug <br> if (p[0].equals(n[0]) == false) { <br> postMsg(newMsg); <br> } <br> //println(s); // debug <br>} <br> <br>[color=red]And these are the errors on python:[/color] <br> <br>running... simpleTweet_01_python <br>arduino msg: #peacefulGlow <br> <br>Traceback (most recent call last): <br> File &quot;C:/Users/Ciaran/Desktop/python final&quot;, line 47, in <br> listenToArduino() <br> File &quot;C:/Users/Ciaran/Desktop/python final&quot;, line 24, in listenToArduino <br> compareMsg(msg.strip()) <br> File &quot;C:/Users/Ciaran/Desktop/python final&quot;, line 31, in compareMsg <br> pM = &quot;&quot;+prevMsg[0]+&quot;&quot; <br>IndexError: list index out of range <br>&gt;&gt;&gt; <br> <br>[color=red][font=Verdana]This is my current python code:[/font][/color] <br> <br> <br>print 'running... simpleTweet_01_python' <br> <br># import libraries <br>import twitter <br>import serial <br>import time <br> <br># connect to arduino via serial port <br>arduino = serial.Serial('COM5', 9600, timeout=1) <br> <br># establish OAuth id with twitter <br>api = twitter.Api(consumer_key='ykaw70kvBc6jVV21eLlWA', <br> consumer_secret='PllQqnwaZV7aYuH33vniloGW2U5fbkfYxef2LQVAK0', <br> access_token_key='20026567-9juOyYchv9k7PXsu7kyrvhpHKkOY3Fg6xTn9vatuA', <br> access_token_secret='AcIhlVX95nvpFYMyk9oh41PWHe3TXYqhMbSy6hLgQ') <br> <br># listen to arduino <br>def listenToArduino(): <br> msg=arduino.readline() <br> if msg &gt; '': <br> print 'arduino msg: '+msg.strip() <br> compareMsg(msg.strip()) <br> <br># avoid duplicate posts <br>def compareMsg(newMsg): <br> # compare the first word from new and old <br> status = api.GetUserTimeline('yourUsername') <br> prevMsg = [s.text for s in status] <br> pM = &quot;&quot;+prevMsg[0]+&quot;&quot; <br> pM = pM.split() <br> nM = newMsg.split() <br> print &quot;prevMsg: &quot;+pM[0] <br> print &quot;newMsg: &quot;+nM[0] <br> if pM[0] != nM[0]: <br> print &quot;bam&quot; <br> postMsg(newMsg) <br> <br># post new message to twitter <br>def postMsg(newMsg): <br> localtime = time.asctime(time.localtime(time.time())) <br> tweet = api.PostUpdate(hello) <br> print &quot;tweeted: &quot;+tweet.text <br> <br>while 1: <br> listenToArduino() <br>_______________________________________________________________________ <br> <br>I know atleast one of the buttons are working as it sends the signal of [color=red]arduino msg: #peacefulGlow <br> <br>[/color] to pyhon when running module but as soon as the button is pressed then error messages appear. <br>My LED is not lighting up at all :( <br> <br>I can send pictures of the circuitboard if needed. <br> <br>Please will someone help me with this. <br>Either contact me here or and email to broadleyutb@googlemail.com would be great <br> <br>Thanks <br> <br> <br>
this is relation to the moodlight twitter mention tutorial you made. <br>I have now got the led to cycle through some colours but it seems to fade in and out nicely then every few seconds it will blink off then back on? <br>and I also do not understand how you are supposed to run python+processing (for button code) at the same time of running the arduino RGB LED code as both can not use the same COM (COM5 in my case) at the same time
Howdy. You are not supposed to run Python and Processing at the same time. The python and processing scripts are meant to be two separate examples of the same project, just to show how it looks when done one way or the other; not supposed to work together. Perhaps this relates to the error you mention above? Try running only Processing or only Python and see what you get. Otherwise, I'm afraid I'm not much help. Good luck!
Hi mate. <br>Im getting errors on processing like, no libraries for twitter4j.http. <br>So I downloaded a jar file called, twitter4j-2.0.9 and draged it. But I was libraries using twitter4j 2.2.5-<br><br>Then another error came up, acces token is ambiguos.<br>And then on the code I put: <br>import twitter4j.http.OAuthToken*;<br><br>And then it says the Token is not visible. <br>Im using mac, I really need help. Thanks.<br>
That is so frustrating! I had to install twitter4j on a few machines and each time I had trouble with the libraries. Unfortunately I forget how I fixed it but it was something like copying the library into each of the two or three possible directories where &quot;Processing&quot; might look for it. Since that's not much of an answer, I suggest you try searching and asking questions at the Twitter4j google group:<br> <a href="http://groups.google.com/group/twitter4j" rel="nofollow">http://groups.google.com/group/twitter4j</a><br> <br> Good luck! If you iron it out please come back and post the answer.&nbsp;
Also, I've got this same project done using Python instead of Processing. <a href="https://www.instructables.com/id/simpleTweet01python/" rel="nofollow">https://www.instructables.com/id/simpleTweet01python/</a><br> <br> Not an answer, but I found Python to be really easy to use. In fact I don't even use Processing at all anymore.
Ok, thank you so much. But I've never used python before. I'll give it a try. <br>Im trying to figure how to install the libraries for mac.
Hi pdxnat,<br> <br> Thanks for the great project.<br> <br> I'm trying to get this code running, but I am stuck installing the library. I've put it in the location you suggested which didn't work. I then tried the default library location (where I have installed other libraries) which is a subdirectory of the sketch folder. This didn't work either.<br> <br> &nbsp;I did find a discussion about installing libraries into Processing <a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1237933931">(http://processing.org/discourse/yabb2/YaBB.pl?num=1237933931</a>) and tried to change the name of the twitter4j-core.jar to twitter4j.jar so that it matched the library name as they suggested. Processing then recognized the library, but gave me the following error:<br> <br> &quot;No library found for twitter4j.http&quot;<br> <br> Any thoughts on what I am doing wrong and why this isn't working?<br> <br> Thanks, Aaron
The bottom line is No, I don't know what's wrong. But it's got to be a fluke and therefore fixable.<br> <br> I have attached the twitter4j.jar file to this instructable page. I'm not sure if you could just use that file or if there's more installation that needs to happen, but it's here for archival purposes now.<br> <br> On my Windows 7 box I've installed the twitter4j jar file here:<br> <em>C:\Program Files\processing-1.5.1\modes\java\libraries\twitter4j\library\twitter4j (executable jar file)</em><br> <br> I think I may have had to exit and reopen Processing, or restart the machine, I don't recall. Anyway, with the executable twitter4j file in that directory, it finally showed up in the Processing IDE under Menu:Sketch&gt;Import Library&gt;twitter4j. But you're saying that's not working for you, right?<br> <br> Well, I did a little surfing and found that I'm a version or so out of date. The libraries can now go into the sketchbook directory, as you seem to know already. This what you mean by &quot;the default library location&quot; yes?<br> <br> Over at <a href="http://www.learningprocessing.com/tutorials/libraries/">http://www.learningprocessing.com/tutorials/libraries/</a> I found this information:<br> <em>&quot;Processing now allows for a &ldquo;libraries&rdquo; folder inside your Processing sketchbook, which is a great deal more convenient than having your 3rd party libraries installed in the Processing application folder.&quot;</em><br> <br> They're saying you can now install a library like twitter4j here (you add the directories into your \My Documents\Processing\ folder):<br> <em>C:\My Documents\Processing\libraries\twitter4j\library\twitter4j (executable jar file)</em><br> <br> This is mentioned again on the Processing site here:&nbsp;<a href="http://wiki.processing.org/w/How_to_Install_a_Contributed_Library">http://wiki.processing.org/w/How_to_Install_a_Contributed_Library</a><br> <em>&quot; libraries must be ... placed within the &quot;libraries&quot; folder of your Processing sketchbook.&quot;</em><br> (To find the Processing sketchbook location on your computer, open the Preferences window from the Processing application and look for the &quot;Sketchbook location&quot; item at the top.)<br> And in the forums here:&nbsp;<a href="http://forum.processing.org/topic/how-to-install-a-contributed-library">http://forum.processing.org/topic/how-to-install-a-contributed-library</a><br> <br> You've tried this both ways and it's not working? I don't know what's up. I'm sorry. Unless someone else contributes here, I'd say ask the Processing forums. They've got a forum just for Contributed Libraries here:&nbsp;<a href="http://forum.processing.org/contributed-library-questions">http://forum.processing.org/contributed-library-questions</a><br> <br> Sorry I don't have the answer for you. It *should* work. ;-)&nbsp;<br> Good luck!
I finally go it to work by taking the twitter4j.jar file attached to this page and put it into &quot;sketchbook&quot;&gt;libraries&gt;twitter4j&gt;library&gt;
Excellent. Thanks for the info.
I've got this same project available using Python instead of Processing, in case that appeals to you. I know that's not an answer (and I want to know when you get twitter4j working) but I figured I'd mention it.<br> <br> <a href="https://www.instructables.com/id/simpleTweet01python/">https://www.instructables.com/id/simpleTweet01python/</a>
Brilliant!Rated5*
Cheers!
Hi - can you be more explicit when you say &quot;install twitter&quot;? I don't see an exe in the download section at all (plus, I'm running linux, so &quot;install&quot; is a term that doesn't mean anything to me :) ).
Howdy, it's actually &quot;install twitter4j&quot;, pronounced twitter-for-jay, as in, 'for java'. It is a java library available here: <a href="http://twitter4j.org/en/index.html#download ">http://twitter4j.org/en/index.html#download</a>&nbsp;. I'm not as familiar w/ linux as I'd like to be, but here's what I think you'll do. Download it from the link; uncompress it; and copy it to the proper directory so Processing knows this is a library it can import.<br> <br> It needs to be in Processing's libraries folder. On Windows, that directory looks like this:<br> C:\Program Files\processing-1.5.1\modes\java\libraries<br> Probably for linux the last few directories are going to be the same:<br> ...&nbsp;processing-1.5.1\modes\java\libraries<br> Within Processing, you'd import the library by starting with the &quot;Sketch&quot; menu:&nbsp;<br> Processing &gt; Sketch &gt; Import Library... &gt; twitter4j<br> And that should do it.&nbsp;
From the link above:<br> <em>Just add twitter4j-core-2.2.3.jar to your application classpath. If you are familiar with Java language, looking into the <a href="http://twitter4j.org/en/javadoc/index.html">JavaDoc </a>should be the shortest way for you to get started.<a href="http://twitter4j.org/en/javadoc/twitter4j/Twitter.html"> twitter4j.Twitter</a> interface is the one you may want to look at first.</em>
Thanks for the reply! I caught the above info in the link, but that didn't seem to help me out too much. And, I don't know java at all, so the JavaDoc is pretty useless :). I may get a chance to poke away at it later...trying to get a test running kinda fast so I can have a little script like yours in my arsenal for the Red Bull Creation finals in a couple of weeks.<br><br>...and then, maybe I'll write an instructable about how to install twitter4j on ubuntu to make it simple :).
I found two discussions in the Processing forums <a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1210090496/0">here</a>&nbsp;and <a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1274657654">here</a>&nbsp;that may / not help. Also, I wrote a Python version of this same project: <a href="https://www.instructables.com/id/simpleTweet01python/">simpleTweet_01 python</a>. Definitely check that out as Python + Ubuntu go hand in hand. I knew absolutely zero about Python when I started that project, so I'm betting you can get it running in no time.<br> <br> Good Luck!
Python definitely made this a lot simpler for me. Thanks a million for writing the instructable on both!
... also, the python version does not use twitter4j, it uses python-twitter and a couple other packages. In the Python v. Processing discussion, I'm native to java but impressed with Python. I will definitely use Python again. In fact, I've got another project that uses both Processing and Python in the same instructable, here: <a href="https://www.instructables.com/id/Twitter-Mention-Mood-Light/">Twitter Mention Mood Light.</a>

About This Instructable

18,537views

27favorites

License:

More by pdxnat:Twitter Mention Mood Light simpleTweet_01 python How to install Python packages on Windows 7 
Add instructable to: