Estoy aprendiendo arduino, pero no me doy cuenta del error, hay un problema de asigación, si alguien me lo puede corregir se lo agradezco
#include <MsTimer2.h>
#include <LiquidCrystal.h>
#include <DHT.h>
#define DHT11PIN 8
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
char* sethum[]={"40-50", "50-60", "60-70","70-80", "80-90"};
int h, chk, cuenta=0, band=1, seg=0, bandseg=0;
const int boton= 7;
const int tiempoAntirebote =10;
int estadoBoton;
int estadoBotonAnterior;
void flash() {
if((seg==30)||(seg==60))
band=1;
seg++;
if(seg==60){
seg=0;
}
}
void setup() {
lcd.begin(16, 2);
pinMode(13, OUTPUT);
MsTimer2::set(1000, flash); // 500ms period
MsTimer2::start();
pinMode(boton,INPUT); //declaramos el boton como entrada
lcd.setCursor(0,0);
lcd.print("Humedad %=");
lcd.setCursor(0,1);
lcd.print("Set.Hum.%=");
}
/Función antirebote/
boolean antirebote (int pin ) {
int contador =0;
boolean estado; // guarda el estado del boton
boolean estadoAnterior; // guarda el ultimo estado del boton
do {
estado = digitalRead (pin);
if (estado != estadoAnterior ){ // comparamos el estado actual
contador = 0; // reiniciamos el contador
estadoAnterior = estado;
}
else{
contador = contador +1; // aumentamos el contador en 1
}
delay (1);
}
while (contador < tiempoAntirebote);
return estado;
}
void loop() {
//******************** Muestra depende del Timer ***************************************
if(band==1){
chk = DHT11.read(DHT11PIN); /acá aparece el error/
h=DHT11.humidity;
lcd.setCursor(11,0);
lcd.print(h);
band=0;
}
//**************************************************************************************
//****************************** Antirebote ********************************************
estadoBoton =digitalRead (boton); //leemos el estado del boton
lcd.setCursor(11,1);
lcd.print(sethum[cuenta]);
if (estadoBoton != estadoBotonAnterior) { //si hay cambio con respeto al estado
if (antirebote (boton)){ //checamos si esta preionado y si lo
esta
cuenta++; //aumentamos la cuenta
if(cuenta==5){
cuenta=0;
}
}
}
estadoBotonAnterior = estadoBoton; // guardamos el estado del boton
//**************************************************************************************
//**************************************** Control *************************************
if((h<40)&&(cuenta==0)){
if((seg>=0)&&(seg<=3)){
digitalWrite(13, HIGH);
}
if((seg>3)&&(seg<60)){
digitalWrite(13, LOW);
}
}
if((h>=40)&&(cuenta==0)){
digitalWrite(13, LOW);
}
if((h<50)&&(cuenta==1)){
if((seg>=0)&&(seg<=3)){
digitalWrite(13, HIGH);
}
if((seg>3)&&(seg<60)){
digitalWrite(13, LOW);
}
}
if((h>=50)&&(cuenta==1)){
digitalWrite(13, LOW);
}
if((h<60)&&(cuenta==2)){
if((seg>=0)&&(seg<=3)){
digitalWrite(13, HIGH);
}
if((seg>3)&&(seg<60)){
digitalWrite(13, LOW);
}
}
if((h>=60)&&(cuenta==2)){
digitalWrite(13, LOW);
}
if((h<70)&&(cuenta==3)){
if((seg>=0)&&(seg<=3)){
digitalWrite(13, HIGH);
}
if((seg>3)&&(seg<60)){
digitalWrite(13, LOW);
}
}
if((h>=70)&&(cuenta==3)){
digitalWrite(13, LOW);
//seg=0;
}
if((h<80)&&(cuenta==4)){
if((seg>=0)&&(seg<=3)){
digitalWrite(13, HIGH);
}
if((seg>3)&&(seg<60)){
digitalWrite(13, LOW);
}
}
if((h>=80)&&(cuenta==4)){
digitalWrite(13, LOW);
}
//**************************************************************************************
}