We feel fine









Idea: Use data gathered from the we feel fine project and display it using the arduino. A query is launched from processing asking for some feelings of persons in pittsburgh and then tranformed into a percentage of bad/good feelings which are assigned to an amount of a certain colour (blue for bad, red for good).

When there is a change in the world, the LED blinks and updates its status.


Processing Code:


import processing.xml.*;

import processing.serial.*;


Serial myPort;  // Create object from Serial class

int val;        // Data received from the serial port

XMLElement xml;

int lastPerGood=0;

int lastPerBad=0;

String buff = “”;

int NEWLINE = 10;


void setup() {

  size(200, 200);


  String portName = Serial.list()[0];

  myPort = new Serial(this, portName, 9600);



void draw() {


  int good=0;

  int bad=0;

  int total=0;

  int perGood=0;

  int perBad=0;


  xml = new XMLElement(this, “http://api.wefeelfine.org:8080/ShowFeelings?display=xml&returnfields=sentence,%20feeling&limit=500&city=Pittsburgh”);


  int numSentences = xml.getChildCount();


  for (int i = 0; i < numSentences; i++) {

    XMLElement kid = xml.getChild(i);

    String id = kid.getStringAttribute(“feeling”); 
















  if(perGood!=lastPerGood || perBad!=lastPerBad){



    println(“\nTotal:”+total+”  Good:”+good+”  Bad:”+bad);

    println(“Good(%):”+perGood+”  Bad(%):”+perBad);










Arduino Code:



int ledBluePin = 9;

int ledRedPin=10;

void setup()


  // begin the serial communication


  pinMode(ledBluePin, OUTPUT);

  pinMode(ledRedPin, OUTPUT);



void loop()


  byte val;



  // check if data has been sent from the computer

  if (Serial.available()) {

    // read the most recent byte (which will be from 0 to 255)

    val = Serial.read();

    if(val==255) blink() else analogWrite(ledBluePin, val*3);

    // set the brightness of the LED





void blink(){

  int i=0;


  analogWrite(ledRedPin, 0);


  analogWrite(ledRedPin, 255);






Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s