Arduino based Office-WTF-Counter

Nikolaus Gradwohl2009-07-03T08:37:00+00:00

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();
}
Tweet This! submit to reddit Digg! Tags: | 28 comments | no trackbacks

See also:

WTF-Counter version2
Smiley-O-Mat
My name is 192.168.159.16
processing ical-flowers-2.0
Training Bike Visualization

Trackbacks

Comments

Leave a response

  1. highpriest 2009-07-03T08:43:17+00:00

    That is something a coupland novel would include.

  2. Erdem 2009-07-03T11:02:33+00:00

    WTF?!?

  3. Sean 2009-07-03T16:36:35+00:00

    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 2009-07-03T19:42:31+00:00

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

  5. Duncan 2009-07-03T20:04:15+00:00

    Somebody just the all the comments!

  6. R-Gu 2009-07-03T21:34:46+00:00

    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 2009-07-04T19:33:41+00:00

    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 2009-07-06T03:07:51+00:00

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

  9. Interiot 2009-07-06T15:03:44+00:00

    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. 2009-07-08T22:18:55+00:00

    What a waste of time and resources.

  11. Jeremy 2009-07-09T21:47:26+00:00

    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 2009-07-15T22:49:11+00:00

    Well said Jeremy!!

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

  13. Eric 2009-07-17T00:12:44+00:00

    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 2009-07-26T15:10:59+00:00

    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 2009-07-31T06:06:25+00:00

    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 2009-09-13T00:33:05+00:00

    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 2010-01-09T20:52:26+00:00

    sparky = moron

  18. ada 2010-01-09T22:50:10+00:00

    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 2010-01-11T17:56:14+00:00

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

  20. Nikolaus Gradwohl 2010-01-11T18:03:54+00:00

    @karmic

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

  21. Online Advertising Agencies 2010-06-15T07:38:45+00:00

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

  22. lieke 2010-10-18T12:10:00+00:00

    i love the use of comic sans

  23. hantu 2011-07-09T02:07:20+00:00

    wtf!!!

  24. vedradijaus 2012-09-13T07:53:44+00:00

    Thanks for sharing such a useful stuff!

  25. gegoefficyfot 2012-11-26T07:05:17+00:00

    WSOOOOOSWOOO
    WSOOOOOSWOOO
    WSOOOOOSWOOO

  26. Yeahhhhh 2013-04-27T19:42:57+00:00

    You realize you could have just used a ticket counter right? Instead of writing code, and installing a button that goes to a module that goes to a computer. Way to overthink it.

  27. BerImmarecick 2013-07-22T22:56:20+00:00

    distinctive|special|exclusive} {design|style|layout|design and style} {demonstrates|shows|displays|illustrates} {unparalleled|unequalled|unmatched|unrivaled} {quality|high quality|top quality|good quality} {and an|as well as an|plus an|with an} {innate|natural|inborn|inbuilt} sultriness.{Ladies|Girls|Females|Women} {are|tend to be|are usually|are generally} {crazy about|in love with|fond of|excited about} {Christian Louboutin|Louboutin|Christian louboutin uk|Christian louboutin shoes} {shoes|footwear|sneakers|shoes or boots}. {If you want|If you would like|If you'd like|If you need} {keep the|keep your|maintain the|maintain your} {same|exact same|identical|very same} {pace|speed|tempo|rate} {with the|using the|with all the|while using} {trend|pattern|craze|development}.{Cheap|Inexpensive|Low-cost|Low cost} {Christian Louboutin|Louboutin|Christian louboutin uk|Christian #file_links\Users\Administrator\Desktop\D1\key.txt,1,N]

  28. burberry shirts 2013-07-30T03:38:47+00:00

    http://www.my-chicken-heart.com/2012/11/3d_cad_1.html#comments

Leave a comment