Hirdetés
Hirdetés
Talpon vagyunk, köszönjük a sok biztatást! Ha segíteni szeretnél, boldogan ajánljuk Előfizetéseinket!
-
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
- GYÖNYÖRŰ iPhone 13 mini 256GB Blue -1 ÉV GARANCIA - Kártyafüggetlen, MS3038, 94% Akkumulátor
- Több mint 70.000 eladott szoftverlicenc
- HIBÁTLAN iPhone 14 128GB Blue -1 ÉV GARANCIA - Kártyafüggetlen, MS3017, 100% Akkumulátor
- LG 27UL550-W - 27" IPS / 3840x2160 4K / 60Hz 5ms / HDR10 / AMD FreeSync
- Olcsó Notebook! Dell Latitude E7280! I5 7300U / 8GB DDR4 / 256GB SSD!
Állásajánlatok
Cég: FOTC
Város: Budapest