2

I am a beginner with no coding background. I am trying to figure out an alarm that tells people how long they have been sitting on their chair. The concept is very simple when the person would sit in his chair it will trigger an event ( maybe a button press) which should trigger the counting of time. if the time exceeds a limit (let's say an hour) a buzzer will go off. The only way to stop the buzzer is to stay away from the chair for let's say a minute. I don't know how to start writing this code, especially how do I make this time counter start with this sitting action ( which might press a button). Its for my class project so any help is highly appriciated.

2 Answers2

1

One idea would be to use force/pressure sensor on chair. You have to find what the sensor outputs when an average person sits on it and calibrate the values accordingly in code. Finally you have to a set threshold value for it. Now if somebody sits on it and if that threshold is exceeded, it means somebody sat on it. So you can now trigger your rtc module or maybe you can use special peripherals called timers , which are inside arduino itself. Both can be used to keep track of time. Tutorials are available for both timers, and ds3231- arduino interfacing. You can easily code. Good luck :-)

Mitu Raj
  • 424
  • 2
  • 9
0

The concept is very simple when the person would sit in his chair it will trigger an event ( maybe a button press) which should trigger the counting of time. if the time exceeds a limit (let's say an hour) a buzzer will go off.

multiple ways, all conceptually identical to yours ask:

1) when a person sits in the chair, it triggers a piece of code that sets an alarm in the dtc. once the dtc alarm goes off, it triggers a state change on a pin linking the dtc to the mcu, which triggers the buzzer;

2) the 2nd approach is similar except that the mcu pulls the dtc constantly for new time. once the new time passes the trigger time sufficiently, a buzzer sounds.

...

this whole thing can be done without the dtc, btw.

dannyf
  • 2,813
  • 11
  • 13