For use with MBED application board
Dependencies: mbed C12832 HCSR04
Revision 1:81cec44cec2e, committed 2021-10-19
- Comitter:
- jbrown57
- Date:
- Tue Oct 19 17:14:52 2021 +0000
- Parent:
- 0:c48b28944702
- Commit message:
- water tank
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
tank.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r c48b28944702 -r 81cec44cec2e main.cpp --- a/main.cpp Tue Oct 12 19:23:55 2021 +0000 +++ b/main.cpp Tue Oct 19 17:14:52 2021 +0000 @@ -11,7 +11,6 @@ PwmOut r (p23); // r = red LED PwmOut g (p24); // g = green LED - int main() { @@ -32,6 +31,7 @@ lcd.cls(); //clear LCD + Timer timer; { @@ -41,7 +41,7 @@ - lcd.print_bm(bitmEmptyTank,80,0); // print Empty Tank at location x=85, y=0 + lcd.print_bm(bitmEmptyTank,80,0); // print Empty Tank at location x=80, y=0 lcd.copy_to_lcd(); //if needed: lcd.locate(0,10); //if needed: lcd.printf("Min. range = %g cm\n\rMax. range = %g cm\n\r", @@ -63,10 +63,11 @@ wait_ms(500 - timer.read_ms()); // time the loop //turn RGB LED red if distance >400mm - if( sensor.getDistance_mm()< 400) r=1; //red light on + + if( sensor.getDistance_mm()< 400) r= 1; //red light on else r = 0; - if( sensor.getDistance_mm()> 400) g=1; //green light on + if( sensor.getDistance_mm()> 400) g=1; //green light on else g=0; //green light off @@ -93,6 +94,7 @@ if( sensor.getDistance_mm() > 440 ) lcd.print_bm(bitmEmptyTank,80,0); //empty tank lcd.copy_to_lcd(); + } }
diff -r c48b28944702 -r 81cec44cec2e tank.h --- a/tank.h Tue Oct 12 19:23:55 2021 +0000 +++ b/tank.h Tue Oct 19 17:14:52 2021 +0000 @@ -17,7 +17,7 @@ // 0xfb = xxxx x-xx - 0xC0, 0x00, 0x00, 0x00, 0x03, // XX__ ____ ____ ____ ___ ____ ____ __XX + 0xDf, 0xff, 0xff, 0xff, 0xfB, // XX_X XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX X_XX 0xDf, 0xff, 0xff, 0xff, 0xfB, // XX_X XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX X_XX 0xDf, 0xff, 0xff, 0xff, 0xfB, // XX_X XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX X_XX @@ -47,7 +47,7 @@ 0xDf, 0xff, 0xff, 0xff, 0xfB, // XX_X XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX X_XX 0xDf, 0xff, 0xff, 0xff, 0xfB, // XX_X XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX X_XX 0xDf, 0xff, 0xff, 0xff, 0xfB, // XX_X XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX X_XX - 0xDf, 0xff, 0xff, 0xff, 0xfB, // XX_X XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX X_XX + 0xC0, 0x00, 0x00, 0x00, 0x03, // XX__ ____ ____ ____ ___ ____ ____ __XX 0xFF, 0xFF, 0xff, 0xFF, 0xFF, // XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX 0xFF, 0xFF, 0xff, 0xFF, 0xFF, // XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX