In filmuletul DHT11 si ATtiny85 la 8MHz am prezentat si partea de setare la 8MHz.
Zona colorata cu galben e partea de stabilizare de 5v realizata cu LM7805, pentru a putea alimenta montajul de la un alimentator sau masina... daca se fac teste cu alimentator de 5V, acea parte poate lipsi.
Sketch-ul folosit de mine este:/*
this sketch is adapted by niq_ro from
http://www.tehnic.go.ro
http://www.niqro.3x.ro
http://nicuflorica.blogspot.ro/
http://arduinotehniq.blogspot.com/
this sketch is made for use a DHT11 sensor with ATtiny85 at 8MHz
* 3-pin Arduino interface for HD44780 LCDs via 74HC595 Shift Register
* by Rowan Simms code@rowansimms.com
* License: Creative Commons - Attribution.
* Full Documentation and Description: http://rowansimms.com/article.php/lcd-hookup-in-seconds
*
* This sketch allows Arduinos to use a shift register to control an LCD, allowing
* a reduction in pins it requires from 6 to 3 while still retaining full control
* including backlight on/off.
* This requires the use of the LiquidCrystal595 library
* available at: http://code.google.com/p/arduino-lcd-3pin/
*/
#include <LiquidCrystal595.h> // include the library
LiquidCrystal595 lcd(0,1,2); // datapin, latchpin, clockpin
#include <dht.h> // http://arduino.cc/playground/Main/DHTLib
#define DHT11_PIN PB3
dht DHT;
byte grad[8] = {
B01110,
B10001,
B10001,
B01110,
B00000,
B00000,
B00000,
};
vid setup() {
lcd.begin(16,2); // 16 characters, 2 rows
lcd.createChar(0, grad);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Wow. 3 pins!");
lcd.setCursor(0,1);
lcd.print("Fabulous");
delay(2000);
lcd.clear();
}
void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
int chk = DHT.read11(DHT11_PIN);
int t=0;
int h=0;
//_delay_ms(200);
h=DHT.humidity;
t=DHT.temperature;
lcd.setCursor(3,0);
lcd.print("t = ");
// lcd.print("+");
lcd.print(t);
lcd.write(byte(0));
lcd.print("C ");
delay(2000);
lcd.setCursor(3,1);
lcd.print("h = ");
lcd.print(h);
lcd.print("%RH ");
delay(2000);
}
Niciun comentariu:
Trimiteți un comentariu