-
PROHARDVER!
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
junhum
tag
Sziasztok!
Nem jövök rá, hogy mit kellene átírnom.
Nano+i2cLCD+DHT22// then define the LCD
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // <<- Add your address here.
#define Rs_pin 0
#define Rw_pin 1
#define En_pin 2
#define BACKLIGHT_PIN 3
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
#include "DHT.h"
#define DHTPIN 2 // what digital pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
void setup(void) {
lcd.begin (16, 2); // <<-- change for your LCD size if needed
//LCD Backlight ON
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home on LCD
lcd.print("Your temperature:");
lcd.clear();
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
delay(1500);
}
void loop(void) {
delay(2000);
int chk = dht.read(DHTPIN);
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("C=");
lcd.print((float)DHT.temperature, 0);
lcd.print(" H=");
lcd.print((float)DHT.humidity, 0);
lcd.print("%");
delay(1000);
lcd.clear();
}Az lcd.print((float)DHT.temperature, 0); és a humidity-nél ezt dobja:
termometar_lcd:82: error: expected primary-expression before '.' token
lcd.print((float)DHT.temperature, 0);
^
termometar_lcd:85: error: expected primary-expression before '.' token
lcd.print((float)DHT.humidity, 0);
^
exit status 1
expected primary-expression before '.' tokenTöbb kódot ollózok össze és hiányában
Új hozzászólás Aktív témák
- Bontatlan Apple 96W USB C hálózati adapter (töltő) eladó
- 16GB RAM 1TB Háttér 10,1" NoName
- Chuwi HiPad Pro 8GB/128GB 10.8" 2K 8mag 2SIM Alu ház 7,5mm 450g
- BONTATLAN STEELSERIES TERMÉKEK BOMBA ÁRON! ÚJ, AZONNAL ÁTVEHETŐ!
- ASUS ROG Strix Scsr 16 G634JZR i9-14900HX, 32GB DDR5, RTX 4080 (2027.08-ig garis)
- ÁRGARANCIA!Épített KomPhone Ryzen 5 4500 16/32/64GB RAM RX 6600 8GB GAMER PC termékbeszámítással
- Törött, Hibás iPhone felvásárlás!!
- Bomba ár! Lenovo IdeaPad 330S-15IKB - i5-8G I 8GB I 256SSD I 15,6" FHD I HDMI I Cam I W11 I Gari!
- IPhone 15 Pro 128GB Szép Állapot! Akku:88% Jótállás: 2026.04.09.-ig
- Csere-Beszámítás! RTX Gamer Számítógép PC Játékra! I5 12400F / RTX 3070 / 32GB DDR4 / 1TB SSD
Állásajánlatok
Cég: Promenade Publishing House Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest