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.
Diff: main.cpp
- Revision:
- 0:f4a7cf9ea593
diff -r 000000000000 -r f4a7cf9ea593 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jul 31 17:21:00 2020 +0000
@@ -0,0 +1,69 @@
+#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);
+ }
+}