Created
January 6, 2014 21:05
-
-
Save tprochazka/8289818 to your computer and use it in GitHub Desktop.
Arduino thermostat example project
This file contains hidden or 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 <DHT.h> | |
| #include <LCD5110_Basic.h> | |
| const int COMFORT_TEMPERATURE = 21; | |
| #define DHTPIN 3 // pin teplotního senzoru | |
| #define DHTTYPE DHT11 // typ teplotního senzoru | |
| #define RELAYPIN 2 // pin relé | |
| LCD5110 myGLCD(8,9,10,11,12); // piny LCD displeje | |
| DHT dht(DHTPIN, DHTTYPE); | |
| extern uint8_t SmallFont[]; | |
| extern uint8_t MediumNumbers[]; | |
| extern uint8_t BigNumbers[]; | |
| void setup() { | |
| Serial.begin(9600); | |
| Serial.println("Thermostat by ATom"); | |
| pinMode(RELAYPIN, OUTPUT); | |
| dht.begin(); | |
| myGLCD.InitLCD(); | |
| } | |
| void loop() { | |
| int humidity = dht.readHumidity(); | |
| int temperature = dht.readTemperature(); | |
| printLCD(temperature, humidity); | |
| if (temperature < COMFORT_TEMPERATURE) { | |
| digitalWrite(RELAYPIN, HIGH); | |
| } else { | |
| digitalWrite(RELAYPIN, LOW); | |
| } | |
| delay(500); | |
| } | |
| void printLCD(int temperature, int humidity ) { | |
| myGLCD.clrScr(); | |
| myGLCD.setFont(SmallFont); | |
| myGLCD.print("Temp.", LEFT, 10); | |
| myGLCD.setFont(BigNumbers); | |
| myGLCD.printNumI(temperature, RIGHT, 0); | |
| myGLCD.setFont(SmallFont); | |
| myGLCD.print("Humidity", LEFT, 39); | |
| myGLCD.setFont(MediumNumbers); | |
| myGLCD.printNumI(humidity, RIGHT, 35); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have an uno r3 board and a dht11 . Im not finding any sketch that will verify for me. new and struggling