works
Fork of SRF05_HelloWorld by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 // Simple program to read the distance from an SRF05 using the SRF05 library 00002 00003 #include "mbed.h" 00004 #include "SRF05.h" 00005 00006 SRF05 srf(p9, p10); 00007 00008 int main() { 00009 float curval; 00010 float percentage; 00011 float tankfull = 10; 00012 float tankempty = 60; 00013 float warning = 10; //percentage 00014 float range = tankempty-tankfull; // 100-(value-5)/range*100 00015 while(1) { 00016 curval = srf.read(); 00017 percentage = 100-(((curval-tankfull)/range)*100); 00018 printf ("Percentage Remaining: %.0f (%.0f)\n\r", percentage, curval); 00019 if (percentage < warning){ 00020 printf ("WARNING: Water Level Below 10% \n\r"); 00021 } 00022 wait(1); 00023 } 00024 }
Generated on Sat Aug 6 2022 18:22:29 by
1.7.2
