Arduino based Office-WTF-Counter

Posted by Nikolaus Gradwohl Fri, 03 Jul 2009 06:37:00 GMT

As in any office, my co-workers and I experience several WTF-Situations during our working day. So we decided to implement a simple system to count the WTF's and use them as a metric for our working climate :-)

we use an "emergency stop"-Button which is connected to an arduino. This arduino sends the string "WTF" on the serial line a little python scrip writes them to a file, another processing app count's the lines in the file and offers the result via http, which is read by a processing app for visualisation ...

wtf-button

wtf-arduino

Arduino Part:

const int buttonPin = 2;
const int ledPin =  13;

int ledState = HIGH;
int buttonState;

int lastButtonState = LOW;

long lastDebounceTime = 0;
long debounceDelay = 200;

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  Serial.println("Hello");
}

void loop() {
  buttonState = digitalRead(buttonPin);

  if ((buttonState == HIGH) && (lastButtonState == LOW) && (millis() - lastDebounceTime) > debounceDelay) {
      Serial.println( "WTF" );

      if (ledState == HIGH) {
        ledState = LOW;
      } else {
        ledState = HIGH;
      }
      lastDebounceTime = millis();
  }

  digitalWrite(ledPin, ledState);
  lastButtonState = buttonState;
}

Python server part1:

import serial

f = open("wtf/current", "aw");

ser = serial.Serial( '/dev/ttyUSB0', 9600, timeout = None )
line = ser.readline()

while line:
        if line[0:3] == "WTF" :
                f.write( line )
        f.flush()
        line = ser.readline()

ser.close()

Python server part2:

from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class WtfHandler(BaseHTTPRequestHandler):
        def do_GET(self):
                f = open('wtf/current')
                count = 0;
                l = f.readline()
                while l:
                        count = count + 1
                        l = f.readline()
                self.send_response(200)
                self.send_header("Content-type", "text/plain")
                self.end_headers()
                self.wfile.write("%d" %count)
                f.close()
                return


if __name__ ==  "__main__":
        try:
                server = HTTPServer(('',8888), WtfHandler)
                server.serve_forever()
        except KeyboardInterrupt:
                server.socket.close()

Processing Part:

void setup() {
  size(500, 100);
  smooth();
  textFont( loadFont( "Verdana-Bold-48.vlw"));
  noLoop();

  start( 10 * 1000 );
}

void draw() {
  background(0);
  fill(255);
  String[] lines = loadStrings("http://armleuchter:8888");
  text( "WTF's so far: " + lines[0], 30, 70 );
}


void start( final int mil ) { //<- mil has to be final to be accessible in run() 
   new Thread() { 
   public void run() {
     while( true ) {     
        delay( mil );
        redraw(); 
      }
   }
 }.start();
}

Tags , , ,  | 21 comments | no trackbacks

Tweet This! submit to reddit Digg!

Comments

  1. highpriest said 6 minutes later:

    That is something a coupland novel would include.

  2. Erdem said about 2 hours later:

    WTF?!?

  3. Sean said about 8 hours later:

    In this economy, with the management brainstorming like mad, and patting themselves on the back for every free-association business enhancement they come up with, I've decided to install one in our advertising department.

    In our case WTF actually will be called CRINGE-IN-HORROR, like some of our customer response emails indicate.

  4. Hal said about 11 hours later:

    This is good, but it would be better if a siren and a red light beacon went off as well.

  5. Duncan said about 11 hours later:

    Somebody just the all the comments!

  6. R-Gu said about 13 hours later:

    This type of device would be better left on the PC (assuming everyone has access to one) That way you have to make a conscience decision to make such a claim.

    Also: I was in jail once (or should I say this one time I was in jail) they had these buttons around the gen pop for indoor officers to hit in case of emergency. That button got bumped into and hit on accident more often than it’s intended use. Since then I was in the same jail and they now have a cover over it. It can still be used for it’s intended purpose but you now have to make a conscience decision.

    ...and the idea is that this be anonymous - bells and whistles and lights and sh*t would ruin that aspect

  7. tapius said 1 day later:

    This has good use as to employee reflections on the direction of the project or business, if you log the problem (maybe one of those really cool giant electronic white boards, so you can have some input) then you can see where the company is going -- how it reflects in the market place, enabling you to develop strategies to combat situations

  8. julapy said 2 days later:

    really nice and simple implementation. love that you can actaully post the code from all these different technologies on the one page.

  9. Interiot said 3 days later:

    The Arduino is not necessary here. It would have been simpler/cheaper to hook the switch directly to the RS232's DCD line, and have the Python script trigger directly off of that.

  10. Andy M. said 5 days later:

    What a waste of time and resources.

  11. Jeremy said 6 days later:

    Interiot: As for the Arduino being a more expensive and complicated, my PC does not have an onboard serial port, which is the trend on most any PC newer than about 3 years old. You can get good USB-RS232 adapters and you can get flaky ones. Good ones are more expensive than an Arduino. Therefore it was actually less wasteful of resources to use the Arduino than it would have been to directly use RS232. Plus the Arduino could be used to handle more buttons and even drive indicators (such as the lava lamps pictured behind the Arduino.)

    Andy M: If you mean wasted time and materials, all indications point to this being done by a fellow geek who probably tinkers with this sort of thing for fun. Remember those things, called hobbies, you did when you were a kid? Most adults still enjoy having hobbies, many of them relating to electronics and tinkering. This was probably entirely built in spare time with spare/discarded hardware just laying around.

    Worst case its providing a few moments of humor and stress relief in what sounds like a fairly stressful environment. Can you really define at what point that benefit is paid back by a waste of resources?

  12. Mike said 12 days later:

    Well said Jeremy!!

    Andy M - You are the waste of time and resources.

  13. Eric said 13 days later:

    Awesome project!

    I´m working on something that needs some sort of similar interface. Could you fill me in on what arduino hardware you had to buy?

    Sorry if you already posted this, but I didn´t see anything.

    Thanks so much!

  14. Nikolaus Gradwohl said 23 days later:

    tnx eric,

    i just used a arduino, a emergency-stop button, and a restistor

    the schematics are the same as the digital-input examples on the processing site

  15. SPARKY said 27 days later:

    WHY COULDN'T SOMEONE JUST DO THIS AS A LED DISPLAY WITH AN UP COUNTER, SO EVERY TIME IT GETS HIT THE LED DISPLAY WILL COUNT UP. THEN ADD A RESET BUTTON, SO YOU CAN KILL THE COUNT AT THE END OF THE DAY? KEEP IT SIMPLE.

  16. ds said 2 months later:

    To Sparky: I think that being able to see what the count is day of leads to folks trying to game the results. In other words, saying "my day is worse than aht the counter shows, so I will hit the button some more times." I think that this could lead to WTF inflation, and nobody wants WTF inflation.

  17. sparkyhater said 6 months later:

    sparky = moron

  18. ada said 6 months later:

    this is the best project i've seen since i've came back from the bits!!

    you should totally build a global net WHATTHEFUCK application, where all of us could contribute ;)

    just picture the simultaneous cascades from the entire world!!!

    this just made my day;)

    please post oin the p5 foruns when you do it!

    i would totally do a vizualization in p5 for this! so fucking great !!!

  19. karmic said 6 months later:

    Great project! Where did you purchase the emergency stop button?

  20. Nikolaus Gradwohl said 6 months later:

    @karmic

    the button is from www.conrad.at (search for "not-aus-taster")

  21. Online Advertising Agencies said 11 months later:

    The best part of this product is we can use in any emergency....

Trackbacks

Use the following link to trackback from your own site:
http://www.local-guru.net/blog/trackbacks?article_id=arduino-based-office-wtf-counter&day=03&month=07&year=2009

(leave url/email »)

   Comment Markup Help Preview comment