Twitter Dongers

Sometimes we feel no particular inspiration to do more that is required of us. this is one of those times. I made a buttoned Arduino that posts dongers to twitter. Its turns out that using non-ASCII text in processing can get weird.

IMG_1131

IMG_1133

Screen Shot 2014-11-16 at 23.38.43

Arduino Code:

int pushButton = 2;
int buttonState = 0;
boolean pushed = false;




void setup() {
  Serial.begin(9600);
  Serial.println("in setup");
  pinMode(pushButton, INPUT);    
}




void loop() {
 
  buttonState = digitalRead(pushButton);
  
  if(buttonState == LOW && pushed == false){
    Serial.println("A");
    pushed = true;
  } else if(buttonState == HIGH && pushed) {
    Serial.println("B");
    pushed = false;
  } else {
    Serial.println("B");
  }
  delay(100);
}

 

Processing Code:

import com.temboo.core.*;
import com.temboo.Library.Twitter.Tweets.*;
import processing.serial.*;
Serial myPort;

// Create a session using your Temboo account application details
TembooSession session = new TembooSession("bruehausu", "TweetTest", "ce6b4e4e5a5547d4b5f4509719ebf417");
String dongers[] = {"╰༼ ・ิ ﹏ ・ิ ༽"
                   ,"ԅ[ •́ ﹏├┬┴┬┴╯"
                   ,"ᕦ༼ •́ – •̀ ༽ᕤ"
                   ,"[ ” ಠ ‸ ಠ ” ]"
                   ,"╏ ◔ _̀ ◔ ╏"};

int dongCount = 0;


ArrayList serialChars;      // Temporary storage for received serial data
int whichValueToAccum = 0;  // Which piece of data am I currently collecting? 
boolean bJustBuilt = false; // Did I just finish collecting a datum?

void setup() {
  // Run the StatusesUpdate Choreo function
  int nPorts = Serial.list().length; 
  for (int i=0; i < nPorts; i++) {
  println("Port " + i + ": " + Serial.list()[i]);
  } 
  
    String portName = Serial.list()[5]; 
  myPort = new Serial(this, portName, 9600);
  serialChars = new ArrayList();
}

void processSerial() {
 
  while (myPort.available () > 0) {
    char aChar = (char) myPort.read();
 
    // You'll need to add a block like one of these 
    // if you want to add a 3rd sensor:
    if (aChar == 'A') {
      runStatusesUpdateChoreo();
      dongCount = (dongCount + 1) % 5 ;
    }
  }
}


void runStatusesUpdateChoreo() {
  // Create the Choreo object using your Temboo session
  StatusesUpdate statusesUpdateChoreo = new StatusesUpdate(session);

  // Set inputs
  statusesUpdateChoreo.setAccessToken("2496575443-x8goxXtw4Dp5BatxwOxkm9IDHbI1tCwokTmQbet");
  statusesUpdateChoreo.setAccessTokenSecret("UmexeEsZnfhCySHdRESYFvj8fOuhPqk9GtAc7AumzQr1F");
  statusesUpdateChoreo.setConsumerSecret("gFzXagXdUhmnLPZOLuzIVEzU6ibf3F1u0asxUrflxlbzsuO0AU");
  statusesUpdateChoreo.setStatusUpdate(dongers[dongCount]);
  statusesUpdateChoreo.setConsumerKey("yLcaFxHKrDwX2C76zSelKFQEz");

  // Run the Choreo and store the results
  StatusesUpdateResultSet statusesUpdateResults = statusesUpdateChoreo.run();
  
  // Print results
  println(statusesUpdateResults.getResponse());

}

void draw() {
  processSerial();
}

 

Comments are closed.