-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino Code for Level Monitoring using Buzzer #59
base: master
Are you sure you want to change the base?
Arduino Code for Level Monitoring using Buzzer #59
Conversation
The code adds an alarm to indicate that the tank is about to overflow. The controller used is Arduino-Uno The detailed description is mentioned in vinitshahdeo#54 fixes vinitshahdeo#54
…tch-1 Added Arduino Code for Level Monitoring Buzzer
Thanks for opening this pull request! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@animeshsrivastava24 Please add a README.md
in hardware
and explain the implementation
+ installation
+ how to run
sections.
…tch-2 Deep Sleep Technique using Timer Wakeup Method
It was accidental, sure I'll do the necessary. |
#59 (comment) Please share the microcontroller using which you have written/tested the code, and how much memory does it consume? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@animeshsrivastava24 Can you please also add a SETUP.md
file and explain the working and how to run sections?
Hello @ramanaditya @vinitshahdeo should I add the mentioned file via a separate PR? |
@animeshsrivastava24 Make the changes in same PR. |
Hello @vinitshahdeo @PragatiVerma18 @ramanaditya
I'll like to make a contribution to the following:
My Solution:
Description
For this we will have to implement a finite state machine.
For our particular problem, I would implement a machine with three states: IDLE, ARMED and ALARM, the ALARM state being the only one in which the buzzer is on.
The transitions would be:
(Say time for ALARM to sound is 15 seconds)
ARMED → ALARM when the level hits 100%
ALARM → IDLE after 15 seconds spent in the ALARM state
IDLE → ARMED when the level gets below 90%
Note that the only difference between IDLE and ARMED is that the IDLE state will not go into ALARM when the level reads 100%, as you have to go through the ARMED state before. The threshold at 90% percent (can be changed as desired, added to maintain any lag in working).
lastBuzzer is the last buzzer activation time (in ms). It's use to control that buzzing stop after 15 seconds. It's zero when the percentage is < 99; it's not zero when percentage >= 100.
The code is based on finite state machine where the state is implicitly encoded into the variables
lastBuzzer
andpercentage
. The implicit state is:ARMED when
lastBuzzer == 0
ALARM when
percentage > 99 && millis() - lastBuzzer < 15000L
IDLE when
percentage > 99 && millis() - lastBuzzer >= 15000L
The line
lastBuzzer = 0
establishes theARMED
state as soon aspercentage ≤ 99
Fixes #54
Type of change
Checklist:
Reviewer: Vinit Shahdeo