1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
#include <DHT.h> #include <DHT_U.h> #include <Adafruit_Sensor.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); DHT mydht(8, DHT11); byte user_value1[8]={ B00000, B00000, B00000, B00000, B00000, B00000, B00000, B00000 }; byte user_value2[8]={ B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000 }; byte user_value3[8]={ B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000 }; byte user_value4[8]={ B11100, B11100, B11100, B11100, B11100, B11100, B11100, B11100 }; byte user_value5[8]={ B11110, B11110, B11110, B11110, B11110, B11110, B11110, B11110 }; byte user_value6[8]={ B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 }; void setup() { Serial.begin(9600); mydht.begin(); lcd.init(); lcd.backlight(); lcd.createChar(0, user_value1); lcd.createChar(1, user_value2); lcd.createChar(2, user_value3); lcd.createChar(3, user_value4); lcd.createChar(4, user_value5); lcd.createChar(5, user_value6); } void loop() { float temp = mydht.readTemperature(); float humi = mydht.readHumidity(); int var=map(temp*10, 240, 319, 0, 80); Serial.print(temp*10); Serial.print(" "); Serial.println(var); lcd.setCursor(0,1); for (int i=0;i<16;i++) { if (i < var/5) { lcd.write(5); } else if (i < var/5+1) { lcd.write(var%5+1); } else { lcd.write(0); } } delay(200); } |