Temboo and Twitter

Having already constructed a vision for my final, I used project 11 to play around and test some of the available components I will be using for my final. As a result I attempted to make a program that would tweet depending on whether or not a force resistor was pressed. I learned how to make arrays and how to store strings in them, and then created a list of a few things that I wanted the computer to tweet. After that I tested it by creating a interface on processing that changed the words depending on if you pressed the resistor or not. When I was finished with that I simply linked it to twitter instead of the interface. As I was testing it somehow, I ended up using all of my available data for Temboo. Luckily that data resets every month so for my final project I will test it simply using processing until my Temboo data limit refreshes. Below are some images of the tweets sent by the force resistor as well as the initial project to send a tweet just from Temboo’s processing code.

Tweeting through my aurdino and force resistor

As the values increase (as you press the resistor) it scrolls through the list of phrases to potentially say.
changing values twitter 3 good please

When you let go the visible phrase changes to the last one you stopped at. Once you hold the resistor down again the process continues.



The results can be seen on the screen and, as I programmed it to, as a tweet.

My code can be seen down below.

Processing Code:

// This program will relay a series of six phrases when the user presses a pressure sensor
// Import the Serial library and create a Serial port handler
import processing.serial.*;
Serial myPort;   

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

// Create a session using your Temboo account application details
TembooSession session = new TembooSession("ritznrubble", "myFirstApp", "1d8cccc701d3473282acd6d52044d86b");


int valueA;  // Sensor Value A
int valueB;  // Sensor Value B
 boolean a=false;
 float i; 
int y= 0;
int update=0;
int mapA;
int valA=0;
String[] sayings= new String[6];
//tracking if c is equal to y or if the value of y changes
int c=y;
int count=0;
void setup(){

  // List my available serial ports
  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();
  //array of sayings
sayings [0]= "That hurts!";
sayings [1]= "Stop pushing!";
sayings [2]= "Pull back!";
sayings [3]= "Under Pressure";
sayings [4]= "So much stress!";
sayings [5]= "The pain!";

void draw(){
 println("check c", c, "check y", y, "check count:", count, "valueA", valueA, "ValA", valA, "mapA", mapA, "update", update);

 if (valueA==0){

if (!a){
   i= random(6);
   y= (int)i;
 update= c; 
 } while(update==c){

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

  // Set credential

  // Set inputs

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



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 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') {
      bJustBuilt = false;
      whichValueToAccum = 0;
    } else if (aChar == 'B') {
      bJustBuilt = false;
      whichValueToAccum = 1;
    } else if (((aChar == 13) || (aChar == 10)) && (!bJustBuilt)) {
      // If we just received a return or newline character, build the number: 
      int accum = 0; 
      int nChars = serialChars.size(); 
      for (int i=0; i < nChars; i++) { 
        int n = (nChars - i) - 1; 
        int aDigit = ((Integer)(serialChars.get(i))).intValue(); 
        accum += aDigit * (int)(pow(10, n));
      // Set the global variable to the number we captured.
      // You'll need to add another block like one of these 
      // if you want to add a 3rd sensor:
      if (whichValueToAccum == 0) {
        valueA = accum;
        // println ("A = " + valueA);
      } else if (whichValueToAccum == 1) {
        valueB = accum;
        // println ("B = " + valueB);
      // Now clear the accumulator
      bJustBuilt = true;
    } else if ((aChar >= 48) && (aChar <= 57)) {
      // If the char is between '0' and '9', save it.
      int aDigit = (int)(aChar - '0'); 

Aurdino Code:

// This Arduino program reads  signals, 
// such as from the force resistor 

int sensorValue1 = 0;  // variable to store the value coming from the other sensor
void setup() {
  Serial.begin(9600);  // initialize serial communications    
void loop() {
  // Read the value from the sensor 

  sensorValue1 = analogRead (A1);  // reads value from Analog input 1    

  Serial.print ("A"); 
  Serial.println (sensorValue1);  
  delay (50);   // wait a fraction of a second, to be polite



For my initial test on using twitter (before making this program), I had processing tweet, “Well did it work?”.

Comments are closed.