An object that tweets.

Well, for this assignment I really had a block. I din’t know what to tweet from my arduino so I… Well… I set up a simple button which completes a circuit telling my arduino to send a serial message which processing reads and thenuses to run my temboo choreo. I updated my choreo to take any string and tweet it. I then created a list of words to explain my project. I apologize for the sorry nature of it, truly.

A messy image of a simple button.

November 17, 2014 at 1027AM

Here’s a fritzing diagram.

BasicButton

My Twitter Feed.

Snap 2014-11-17 at 11.30.17

My Arduino Code.

int digPort = 8;
int buttonPushed = 0;
int buttonDown = 0;
int count = 0;

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

void loop() {
    buttonPushed = digitalRead(digPort);
    
    if (buttonPushed == HIGH && buttonDown == 0) {
      Serial.println("A");
      Serial.println(count);
      buttonDown = 1;
      count += 1;
    } else if (buttonPushed == LOW && buttonDown == 1) {
      buttonDown = 0;
    }
    delay(100);

} 

My Processing Code.

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

String not[] = {"nothing",
                "I have absolutely nothing",
                "to make"};
                
Serial myPort;

// Create a session using your Temboo account application details
TembooSession session = new TembooSession("luxapodular", "myFirstApp", "d731d22a81a14393a5be783117d2a8ce");

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?

int notIndex = 0;

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

void draw() {
  doEt();
}

void doEt() {
   while (myPort.available () > 0) {
    char aChar = (char) myPort.read();
 
    if (aChar == 'A') {
      String thingToSay = not[notIndex];
      notIndex = (notIndex + 1) % 3;
      println(thingToSay);
      runStatusesUpdateChoreo(thingToSay);
    }
  }
}

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

  // Set inputs
  statusesUpdateChoreo.setAccessToken("2768964284-CkF5gMrUdhc07hXBJybfH06MVVvgUrgJfDuncfd");
  statusesUpdateChoreo.setAccessTokenSecret("5pm0mlgBuhdx2LVn5Gcj9ehldJtj8AhsI5jyffv25mphb");
  statusesUpdateChoreo.setConsumerSecret("yKVbJn9fnP2oArvBVhE94yiiyoj8FgpiqYy0NKZew3McpxACLe");
  statusesUpdateChoreo.setStatusUpdate(string);
  statusesUpdateChoreo.setConsumerKey("AlVDRqLH5OIL6XWrHyPi9Ikjf");

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

Comments are closed.