Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SRF05_HelloWorld by
Revision 7:974ba1b166ad, committed 2016-12-06
- Comitter:
- Aidan2521
- Date:
- Tue Dec 06 16:41:06 2016 +0000
- Parent:
- 6:fae63ea5ba75
- Commit message:
- Displays warning message when below 10%; changed tank values
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r fae63ea5ba75 -r 974ba1b166ad main.cpp --- a/main.cpp Tue Dec 06 16:19:08 2016 +0000 +++ b/main.cpp Tue Dec 06 16:41:06 2016 +0000 @@ -8,13 +8,17 @@ int main() { float curval; float percentage; - float tankfull = 5; - float tankempty = 35; + float tankfull = 10; + float tankempty = 60; + float warning = 10; //percentage float range = tankempty-tankfull; // 100-(value-5)/range*100 while(1) { curval = srf.read(); - percentage = 100-(((curval-5)/range)*100); - printf ("Percentage Remaining: %.0f (%.0f)\n\r", percentage, curval); - wait(0.2); + percentage = 100-(((curval-tankfull)/range)*100); + printf ("Percentage Remaining: %.0f (%.0f)\n\r", percentage, curval); + if (percentage < warning){ + printf ("WARNING: Water Level Below 10% \n\r"); + } + wait(1); } } \ No newline at end of file