Last active
June 22, 2016 06:39
-
-
Save taylanpince/5258617a82acd74ca559d5aa4ac32d36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LCD5110_Basic.h> | |
LCD5110 LCDScreen(8,9,10,11,12); | |
extern uint8_t logoHipo1[] ; // for picture 1 | |
extern uint8_t logoHipo2[] ; // for picture 2 | |
extern uint8_t MediumNumbers[]; | |
extern uint8_t SmallFont[]; | |
int motionDetectorPin = 4; | |
int motionDetectorValue = 0; | |
int humiditySensorPin = A0; | |
int humiditySensorValue; | |
void setup() { | |
pinMode(7,OUTPUT); | |
digitalWrite(7,HIGH); | |
pinMode (motionDetectorPin, INPUT); | |
LCDScreen.InitLCD(); // start screen | |
LCDScreen.setContrast(70); | |
Serial.begin(9600); | |
} | |
void loop() { | |
LCDScreen.clrScr(); // clear screen | |
motionDetectorValue = digitalRead(motionDetectorPin); // read motion sensor | |
if(motionDetectorValue == HIGH) { // if there is a motion | |
LCDScreen.drawBitmap(0, 0, logoHipo1, 84, 48); // show picture 1 | |
delay(1000); | |
for (int i = 0; i < 1; i++) { | |
LCDScreen.invert(true); | |
delay(500); | |
LCDScreen.invert(false); | |
delay(500); | |
} | |
delay(1000); | |
LCDScreen.clrScr(); | |
humiditySensorValue = analogRead(humiditySensorPin); // read result of humidity sensor | |
LCDScreen.setFont(SmallFont); | |
LCDScreen.print("Humidity :", LEFT, 0); // printf on the screen | |
LCDScreen.setFont(MediumNumbers); | |
LCDScreen.printNumF(humiditySensorValue, 0, CENTER, 16); | |
delay(1000); | |
LCDScreen.clrScr(); | |
if(humiditySensorValue > 800 && humiditySensorValue < 1024) { // determine three different station | |
LCDScreen.setFont(SmallFont); | |
LCDScreen.print("Need Water! ", CENTER , 20); | |
} else if(humiditySensorValue > 300 && humiditySensorValue < 799) { | |
LCDScreen.setFont(SmallFont); | |
LCDScreen.print("normal ", CENTER , 20); | |
} else { | |
LCDScreen.setFont(SmallFont); | |
LCDScreen.print("Too Humid! " , LEFT, 0); | |
LCDScreen.print("Please don't ", LEFT, 16); | |
LCDScreen.print("put more water", LEFT , 32); | |
} | |
delay(4000); | |
LCDScreen.clrScr(); | |
LCDScreen.drawBitmap(0, 0, logoHipo2, 84, 48); // show picture 2 | |
delay(1000); | |
for (int i = 0; i < 1; i++) { | |
LCDScreen.invert(true); | |
delay(500); | |
LCDScreen.invert(false); | |
delay(500); | |
} | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment