Introduction: Arduino Get Up and Move

as we all spend an increasing amount of time sitting at our desks it is easy to get engrossed in what we are doing and loose track of time.

It is said that we should get up and move from our seat at least once every hour, but who wants to be watching the clock?

Using a very simple set up, Arduino has the answer: a sensor to see that you are in the chair, a timer to see how long you've been there and a buzzer to tell you to get up.

For this instructable you will need:

1 Arduino (I used an Uno but any of them will do)

1 IR Distance Sensor

1 Piezo Buzzer

Arduino IDE

And preferably a battery power source.

Step 1: The Wiring Set Up

The IR distance sensor feeds a digital high (or a 1) when it is passive and not making a detection, when an object comes within range the output drops to a digital low (or 0).

For this set up we will use Digital Pin 2 as an input, connect the yellow wire from the sensor to pin 2.

The sensor also requires a 5V supply to the red wire and a 0V GND to the black wire.

The piezo buzzer requires an alternating supply to make the buzz, for this we will connect the negative wire to GND and the positive wire to one of the PWM (pulse width modulation) pins, in this case pin 9.

For my set up I powered the board over USB but to make it practical it would need a battery (and a case as the whole set up is a little delicate).

Step 2: Coding

The code is simple, you can copy and paste from below.

I simply declare that pin 2 is an input and assign the name input to the value coming off pin 2.

I set pin 9 as an output and name it speaker.

I also needed a timer so I called this count.

Using loops the code monitors the output of the sensor, when someone sits in the chair the sensor goes low and the code enters the loop adding 1 to the count each time the program loops, I have a delay of 1000 in the loop, this pauses the program for 1 second (now we have a timer), I'm sure there is a timer function but as I said this is the quick and dirty way to do this.

The program looks for the timer to reach 3600 seconds (1 hour), if the program reaches this number and you haven't moved, BUZZZZ. The buzzer uses the tone command, this requires the code tone(pin,frequency,duration). The buzzer in this case beeps for one second each loop and will continue to beep until you get out of the chair to reset.

However if you have gotten up before the hour the sensor goes high and the timer resets.

int input = 0;
int speaker = 9; int count = 0;

void setup() { Serial.begin(9600); pinMode(speaker, OUTPUT); pinMode(2,INPUT); }

void loop() { input = digitalRead(2); if(input == LOW) { count = count + 1; delay(1000); if (count > 3600) { tone(speaker,1200,1000); } } if (input == HIGH) { count = 0; } }

Step 3: Mount Up and Test

I simply stuck the sensor to the arm of the chair with some tape, this allowed me to get the position correct. Initially I mounted it at the top the the chair back but I found that as I got interested in things I tend to lean forward and out of the range of the sensor.

I think the next step will be to monitor the time after you get out of the chair so it doesn't instantly reset, this will force you to stay up for say 5 mins to stretch and if you get back in too early buzz again.

I hope this helps your back...

Comments

About This Instructable

336views

7favorites

License:

Bio: I am an automation engineer but I will give anything a go. I don't know if you call if pessimism or just being an ... More »
More by Left-field Designs:Automotive Plastic Welding RepairZip-Tie Cable ManagementVery Fidgety Fidget
Add instructable to: