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.
main.cpp
- Committer:
- alanffrench
- Date:
- 2020-07-31
- Revision:
- 0:f4a7cf9ea593
File content as of revision 0:f4a7cf9ea593:
#include "mbed.h" #include "C12832_lcd.h" const float WaterSetPoint = 0.5f; C12832_LCD lcd; //define object lcd AnalogIn WaterLevelSensor(p19); //Left pot simulates level of water AnalogIn ChlorineLevelSensor(p20); //right pot simulater level of chlorine int main() { lcd.cls(); //clear lcd lcd.set_contrast(15); //lcd contrast set value 15 (0-63) while(1) { lcd.cls(); float WaterLevel = WaterLevelSensor; float ChlorineLevel = ChlorineLevelSensor; lcd.locate(0,0); lcd.printf("Chlorine : %.2f",ChlorineLevel); lcd.locate(0,9); lcd.printf("Water : %.2f",WaterLevel); float WaterError = WaterSetPoint - WaterLevel; if(WaterError > 0) { lcd.locate(0,18); lcd.printf("Pump ON "); } else { lcd.locate(0,18); lcd.printf("Pump OFF"); } if(WaterError > 0) { lcd.locate(0,18); lcd.printf("Pump ON "); } else { lcd.locate(0,18); lcd.printf("Pump OFF"); } if(ChlorineLevel > 0.2f) { lcd.locate(50,18); lcd.printf("Cl:OFF"); } if((ChlorineLevel <=0.2)&&(ChlorineLevel> 0.1f)) { lcd.locate(50,18); lcd.printf("Cl: 1 shot"); } if(ChlorineLevel <=0.1) { lcd.locate(50,18); lcd.printf("Cl: 2 shots"); } wait(1); } }