Developing Communities Be Good Do Good
Chandler 85248
chandan
/* moisture/water sensor with LCD display*/
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int colorR = 0;
const int colorG = 255;
const int colorB = 0;
const int D2_low = 2;
int SenStateH = 0;
void setup() { // set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB); // Print a message to the LCD.
lcd.clear(); lcd.setCursor(0,0); lcd.print("Greetings from ");
lcd.setCursor(0,1);
lcd.print("TIES Academy!");
delay(10000); pinMode(D2_low, INPUT);
}
void loop() {
SenStateH = digitalRead(D2_low);
if(SenStateH == LOW){
lcd.setRGB(255,0,0);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Low Water Level!");
lcd.setCursor(0,1);
lcd.print("Please Refill!");
delay(1000);
}
else if(SenStateH == HIGH){
lcd.setRGB(0,255,0);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Water Level!");
lcd.setCursor(0,1);
lcd.print("Perfect!");
delay(1000);
}
else {
lcd.noDisplay();
delay(500);
lcd.display();
delay(500);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
// lcd.setCursor(0, 1);
// print the number of seconds since reset:
// lcd.print(millis()/1000);
}
}
/********************************************************************************************************* END FILE*********************************************************************************************************/
Copyright 2019 Chandan Shamala Library. All rights reserved.
Chandler 85248
chandan