Error codes on twitter mood light tutorial (processing+python)

Hey guys i’m pretty new to arduino but have been working endlessly on this tutorial:

So i am not ready to give up.
I think I may have installed all of the packages for python successfuly but I am not too sure (is there anyway to text)
I’ve worked my way out of most of the problems im facing in creating this.
These is the final problems I am experiencing them and i’m all out of ideas now.
Please help smiley

This is my error codes (processing):

Stable Library

Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7

[1] “COM7”
[2] “COM8” Unknown Application
at processing.serial.Serial.(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at simpleTweet_00_p.setup(
at processing.core.PApplet.handleDraw(Unknown Source)
at Source)
Exception in thread “Animation Thread” java.lang.RuntimeException: Error inside Serial.()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at processing.serial.Serial.(Unknown Source)
at simpleTweet_00_p.setup(
at processing.core.PApplet.handleDraw(Unknown Source)
at Source)

This is my current processing code:

import processing.serial.*;

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

static String OAuthConsumerKey = “ykaw70kvBc6jVV21eLlWA”;
static String OAuthConsumerSecret = “PllQqnwaZV7aYuH33vniloGW2U5fbkfYxef2LQVAK0”;
static String AccessToken = “20026567-9juOyYchv9k7PXsu7kyrvhpHKkOY3Fg6xTn9vatuA”;
static String AccessTokenSecret = “AcIhlVX95nvpFYMyk9oh41PWHe3TXYqhMbSy6hLgQ”;

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

void setup() {
size(125, 125);
String arduinoPort = Serial.list()[0];
arduino = new Serial(this, arduinoPort, 9600); ERROR BEGINS ON THIS LINE

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

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

void draw() {
text(“simpleTweet_00”, 18, 45);
text("@msg_box", 30, 70);

void listenToArduino() {
String msgOut = “”;
int arduinoMsg = 0;
if (arduino.available() >= 1) {
arduinoMsg =;
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) {
//println(s); // debug

And these are the errors on python:

running… simpleTweet_01_python
arduino msg: #peacefulGlow

Traceback (most recent call last):
File “C:/Users/Ciaran/Desktop/python final”, line 47, in
File “C:/Users/Ciaran/Desktop/python final”, line 24, in listenToArduino
File “C:/Users/Ciaran/Desktop/python final”, line 31, in compareMsg
pM = “”+prevMsg[0]+""
IndexError: list index out of range

This is my current python code:

print ‘running… simpleTweet_01_python’

import libraries

import twitter
import serial
import time

connect to arduino via serial port

arduino = serial.Serial(‘COM5’, 9600, timeout=1)

establish OAuth id with twitter

api = twitter.Api(consumer_key=‘ykaw70kvBc6jVV21eLlWA’,

listen to arduino

def listenToArduino():
if msg > ‘’:
print 'arduino msg: '+msg.strip()

avoid duplicate posts

def compareMsg(newMsg):

compare the first word from new and old

status = api.GetUserTimeline(‘yourUsername’)
prevMsg = [s.text for s in status]
pM = “”+prevMsg[0]+""
pM = pM.split()
nM = newMsg.split()
print "prevMsg: "+pM[0]
print "newMsg: "+nM[0]
if pM[0] != nM[0]:
print “bam”

post new message to twitter

def postMsg(newMsg):
localtime = time.asctime(time.localtime(time.time()))
tweet = api.PostUpdate(hello)
print "tweeted: "+tweet.text

while 1:

I know atleast one of the buttons are working as it sends the signal of arduino msg: #peacefulGlow

to pyhon when running module but as soon as the button is pressed then error messages appear.
My LED is not lighting up at all smiley-sad

I can send pictures of the circuitboard if needed.

Please will someone help me with this.
Either contact me here or and email to would be great


Please don't post the same thing in multiple places (cross posting). If its not the right place, a moderator will move it.

Thanks! Moderator (this thread now locked)