


Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!



#include #include #include #include #include LiquidCrystal_I2C lcd(0x3f,16,2); Servo servo; DHT dht(8,DHT11); void setup() { lcd.init(); lcd.backlight(); servo.attach(9); servo.write(0); dht.begin(); pinMode(6,OUTPUT); ANALOG IN ATMEGA328P-PU 1121 Reset BTN ON www.TheEngineeringProjects.com PD0/RXD PD1/TXD PD2/INT ~ PD3/INT1/OC2B PD4/T0/XCK ~ PD5/T1/OC0B ~ PD7/AIN PC5/ADC5/SCL PC4/ADC4/SDA PC3/ADC PC2/ADC PC1/ADC PC0/ADC RESET PB0/ICP1/CLKO ~ PB1/OC1A ~ PB2/OC1B ~ PB3/MOSI/OC2A PD7/AIN PB4/MISO PB5/SCK AREF 0 1 2 3 4 5 6 7 8 9 10 11 12 13 A A A A A A ARD ARDUINO UNO SCL 14 SDA 15 INT 13 A 1 A 2 A 3 P 4 P 5 P 6 P 7 P 9 P 10 P 11 P 12 U PCF D 14 D 13 D 12 D 11 D 10 D 9 D 8 D 7 E^ 6 RW 5 RS 4 VSS 1 VDD 2 VEE 3 LCD LM016L +88. 89 29 %RH > °C (^2) DATA (^1) VDD (^4) GND U DHT R 330 D LED-GREEN
digitalWrite(6,LOW); Serial.begin(9600); } int temperatura; int humedad; int angulo=0; int led=0; String msg, angTxt, ledTxt; void loop() { temperatura = dht.readTemperature(); humedad = dht.readHumidity(); lcd.clear(); lcd.print("Temp: "); lcd.print(temperatura); lcd.print(" gC"); lcd.setCursor(0,1); lcd.print("H.Rel: "); lcd.print(humedad); lcd.print("%"); Serial.print(temperatura); Serial.print(","); Serial.println(humedad); if(Serial.available()){ msg = Serial.readString(); angTxt=msg.substring(0,msg.indexOf(',')); ledTxt=msg.substring(msg.indexOf(',')+1,msg.length()); angulo=angTxt.toInt(); led=ledTxt.toInt(); servo.write(angulo); if(led==0) digitalWrite(6,LOW); else if(led==1) digitalWrite(6,HIGH); Serial.print(angulo); Serial.print(","); Serial.println(led); } delay(1000); lcd.clear(); lcd.print("Ang: "); lcd.print(angulo); lcd.print(" gr"); lcd.setCursor(0,1); if(led==0) lcd.print("Led: Apagado"); else if(led==1) lcd.print("Led: Encendido"); delay(2000); }
if (rbApagar.Checked == true) datosEnv = datosEnv + "0"; else if (rbEncender.Checked == true) datosEnv = datosEnv + "1"; tbHR.Text = datosEnv; serialPort1.Write(datosEnv); } }