The Nod-Off Hat

Ah…retroactive blogging.

Our first assignment for sociable objects was to address a problem on the ITP floor. I decided to tackle one near and dear to my heart: The problem of nodding off while trying to get work done. On more then one occasion over the past year, I’ve woken up with keyboard tread marks on my cheek and IC’s in my hair.

I once even tried to use an Arduino for a pillow…Turns out that drool and micro controllers don’t mix.

Anyway, in order to make a nod-off alarm, I decided to attach an accelerometer to my hat. The accelerometer would act as a sophisticated tilt sensor…If my head tilts too far forward, or too far to the side, an annoying piezo buzzer sounds, waking me up.

This all worked out pretty well. I can’t help but think of this also as some sort of Posture-o-meter or something. Maybe I’ll trying messing around with the Y-axis value in the future.

This project was pretty simple and straightforward, but also represents the frist time that I’ve written code in MONTHS. It took me a little while to get back in the swing of things, but it felt good to be coding (the main reason I’m taking this class).

Anyway, here’s the code, again, simple for most:

(photos of the board coming soon)

int analog0 = 0; // select the input pin for the potentiometer
int XaxisVal0 = 0; // variable to store the value coming from the sensor
int squirtPin = 13; // on/off for the squirtgun

void setup() {
Serial.begin(9600); // use the serial port to send the values back to the computer
pinMode(squirtPin, OUTPUT); //declare squirtPin an output
}

void loop() {
XaxisVal0 = analogRead(analog0); // read the value from the sensor
if(XaxisVal0 > 150 || XaxisVal0 < 87){digitalWrite(squirtPin, HIGH);
}
else
{digitalWrite(squirtPin, LOW);
}

Serial.println(”XaxisVal0″); // print the value to the serial port
Serial.println(XaxisVal0); // print the value to the serial port
}

Leave a Reply