Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #include<DHT.h>
- //#include <EnableInterrupt.h>
- //
- //// Modify this at your leisure. Refer to https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
- //#if defined __AVR_ATmega640__ || defined __AVR_ATmega2560__ || defined __AVR_ATmega1280__ || \
- // defined __AVR_ATmega1281__ || defined __AVR_ATmega2561__
- //#define ARDUINOPIN 10
- //#else
- //// Pin 7 is useful on Arduino Uno, Leonardo, Mighty1284, ATtiny84...
- //#define ARDUINOPIN 7
- //#endif
- //
- //volatile uint16_t interruptCount=0; // The count will go back to 0 after hitting 65535.
- //
- //void interruptFunction() {
- // interruptCount++;
- //}
- const int DHTPIN = 2; //Pin 2
- const int DHTTYPE = DHT11;
- const int buttonInc = 3;
- DHT dht(DHTPIN, DHTTYPE);
- int target_temp = 60;
- LiquidCrystal_I2C lcd(0x27,16,2);
- void setup() {
- Serial.begin(9600);
- lcd.init();
- lcd.backlight();
- pinMode(buttonInc, INPUT);
- // #ifdef MIGHTY1284
- // DDRA=0x0; DDRB=0x0; DDRC=0x0; DDRD=0x0; // set all pins as inputs
- // PORTA=0xFF; PORTB=0xFF; PORTC=0xFF; PORTD=0xFF; // turn on all pullup resistors.
- //#else
- // pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins
- //#endif
- // enableInterrupt(ARDUINOPIN, interruptFunction, CHANGE);
- }
- void loop() {
- float t = dht.readTemperature();
- lcd.clear();
- lcd.print("Target temp: ");
- lcd.print(target_temp);
- lcd.setCursor(0,1);
- lcd.print("Temp: ");
- lcd.print(t);
- Serial.print("Button :");
- Serial.println(digitalRead(3));
- if (digitalRead(buttonInc)) {
- target_temp = target_temp + 1;
- lcd.setCursor(0,0);
- lcd.print("Target temp: ");
- lcd.print(target_temp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment