Guest User

Untitled

a guest
Oct 1st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3. #include<DHT.h>
  4.  
  5. //#include <EnableInterrupt.h>
  6. //
  7. //// Modify this at your leisure. Refer to https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary
  8. //#if defined __AVR_ATmega640__ || defined __AVR_ATmega2560__ || defined __AVR_ATmega1280__ || \
  9. //        defined __AVR_ATmega1281__ || defined __AVR_ATmega2561__
  10. //#define ARDUINOPIN 10
  11. //#else
  12. //// Pin 7 is useful on Arduino Uno, Leonardo, Mighty1284, ATtiny84...
  13. //#define ARDUINOPIN 7
  14. //#endif
  15. //
  16. //volatile uint16_t interruptCount=0; // The count will go back to 0 after hitting 65535.
  17. //
  18. //void interruptFunction() {
  19. //  interruptCount++;
  20. //}
  21.  
  22.  
  23. const int DHTPIN = 2;       //Pin 2
  24. const int DHTTYPE = DHT11;
  25. const int buttonInc = 3;
  26.  
  27. DHT dht(DHTPIN, DHTTYPE);
  28. int target_temp = 60;
  29.  
  30. LiquidCrystal_I2C lcd(0x27,16,2);
  31.  
  32.  
  33.  
  34. void setup() {
  35.   Serial.begin(9600);
  36.   lcd.init();      
  37.   lcd.backlight();  
  38.  
  39.   pinMode(buttonInc, INPUT);
  40.  
  41. //  #ifdef MIGHTY1284
  42. //  DDRA=0x0;    DDRB=0x0;   DDRC=0x0;   DDRD=0x0; // set all pins as inputs
  43. //  PORTA=0xFF; PORTB=0xFF; PORTC=0xFF; PORTD=0xFF; // turn on all pullup resistors.
  44. //#else
  45. //  pinMode(ARDUINOPIN, INPUT_PULLUP);  // See http://arduino.cc/en/Tutorial/DigitalPins
  46. //#endif
  47. //  enableInterrupt(ARDUINOPIN, interruptFunction, CHANGE);
  48. }
  49.  
  50. void loop() {
  51.   float t = dht.readTemperature();
  52.   lcd.clear();
  53.   lcd.print("Target temp: ");
  54.   lcd.print(target_temp);
  55.   lcd.setCursor(0,1);
  56.   lcd.print("Temp: ");
  57.   lcd.print(t);
  58.   Serial.print("Button :");
  59.   Serial.println(digitalRead(3));
  60.  
  61.   if (digitalRead(buttonInc)) {
  62.     target_temp = target_temp + 1;
  63.     lcd.setCursor(0,0);
  64.     lcd.print("Target temp: ");
  65.     lcd.print(target_temp);
  66.   }
  67.  
  68.            
  69.  
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment