SVty

Arduino MHT11 TVout

Mar 12th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.53 KB | None | 0 0
  1. //Měření teplot senzorem MHT11 a výstupem na TV přes TVout.h
  2. #include <TVout.h>
  3. #include <fontALL.h>
  4. #include <dht11.h>
  5. TVout TV;
  6. dht11 DHT11;
  7. const int tlPin = 4;
  8. int mit=100;
  9. int mat=0;
  10. int tep=100;
  11. int vlh=100;
  12. int prt=100;
  13. int tlState = 0;
  14. #define DHT11PIN 2
  15.  
  16. void setup() {
  17.   pinMode(tlPin, INPUT);
  18.   TV.begin(PAL,128,96);
  19.   TV.select_font(font6x8);
  20.   TV.clear_screen();
  21.   TV.fill(BLACK);
  22.   //---------------
  23.   TV.println("Stanovo mereni teplotteplotnim senzorem");
  24.   TV.println("MHT11");
  25.   TV.println(40,76,"Moment....");
  26.   delay(6000);
  27.   //---------------
  28.   TV.clear_screen();
  29.   TV.select_font(font4x6);
  30.   TV.println(0,0,"Teplotni senzory");
  31.   TV.println(0,7,"MHT11");
  32.   TV.println(2,15,"Teplota:");
  33.   TV.println(95,15,"stupnu");
  34.   TV.println(2,23,"Vlhkost:");
  35.   TV.println(95,23,"procent");
  36.   TV.println(2,31,"Maximalni teplota:");
  37.   TV.println(95,31,"stupnu");
  38.   TV.println(2,39,"Minimalni teplota:");
  39.   TV.println(95,39,"stupnu");
  40.   TV.println(2,47,"Prumerna teplota:");
  41.   TV.println(95,47,"stupnu");
  42. }
  43.  
  44. void loop() {
  45.   tlState = digitalRead(tlPin);
  46.   if (tlState == HIGH) {
  47.     mat = 0;
  48.     mit = 0;
  49.   }
  50.   //hodnoty
  51.   DHT11.read(DHT11PIN);
  52.   tep = (float)DHT11.temperature, 0;
  53.   vlh = (float)DHT11.humidity, 0;
  54.   //vypocet
  55.   if(mat < tep) {
  56.     mat = tep;
  57.   }
  58.   if (mit > tep or mit == 0) {
  59.     mit = tep;
  60.   }
  61.   prt = (mit + mat)/2;
  62.   //zobrazeni
  63.   TV.print(80,15,tep);
  64.   TV.print(80,23,vlh);
  65.   TV.print(80,31,mat);
  66.   TV.print(80,39,mit);
  67.   TV.print(80,47,prt);
  68.   delay(500);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment