Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Měření teplot senzorem MHT11 a výstupem na TV přes TVout.h
- #include <TVout.h>
- #include <fontALL.h>
- #include <dht11.h>
- TVout TV;
- dht11 DHT11;
- const int tlPin = 4;
- int mit=100;
- int mat=0;
- int tep=100;
- int vlh=100;
- int prt=100;
- int tlState = 0;
- #define DHT11PIN 2
- void setup() {
- pinMode(tlPin, INPUT);
- TV.begin(PAL,128,96);
- TV.select_font(font6x8);
- TV.clear_screen();
- TV.fill(BLACK);
- //---------------
- TV.println("Stanovo mereni teplotteplotnim senzorem");
- TV.println("MHT11");
- TV.println(40,76,"Moment....");
- delay(6000);
- //---------------
- TV.clear_screen();
- TV.select_font(font4x6);
- TV.println(0,0,"Teplotni senzory");
- TV.println(0,7,"MHT11");
- TV.println(2,15,"Teplota:");
- TV.println(95,15,"stupnu");
- TV.println(2,23,"Vlhkost:");
- TV.println(95,23,"procent");
- TV.println(2,31,"Maximalni teplota:");
- TV.println(95,31,"stupnu");
- TV.println(2,39,"Minimalni teplota:");
- TV.println(95,39,"stupnu");
- TV.println(2,47,"Prumerna teplota:");
- TV.println(95,47,"stupnu");
- }
- void loop() {
- tlState = digitalRead(tlPin);
- if (tlState == HIGH) {
- mat = 0;
- mit = 0;
- }
- //hodnoty
- DHT11.read(DHT11PIN);
- tep = (float)DHT11.temperature, 0;
- vlh = (float)DHT11.humidity, 0;
- //vypocet
- if(mat < tep) {
- mat = tep;
- }
- if (mit > tep or mit == 0) {
- mit = tep;
- }
- prt = (mit + mat)/2;
- //zobrazeni
- TV.print(80,15,tep);
- TV.print(80,23,vlh);
- TV.print(80,31,mat);
- TV.print(80,39,mit);
- TV.print(80,47,prt);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment