LCD keypad Shield With UV UVM-30A

I'm trying to get an LCD reader to show my data from my UV sensor, I don't understand this appears in the code---->

#include <LiquidCrystal.h>

LiquidCrystal lcd(8,9,4,5,6,7);
#define pinSensorUV    A5
#define divisor        20

 
 int indiceUV;
  
void setup() {
 lcd.begin(16,2);
 Serial.begin(9600);
 pinMode(pinSensorUV, INPUT);
 lcd.setCursor(0,0);  
 lcd.print("INDICE ");  
 lcd.setCursor(0,1);  
 lcd.print("UV :");

}

void loop() {
  // put your main code here, to run repeatedly:
lcd.setCursor(8,1);  
 
  lcd.print (indiceUV);


  delay(500); // DELAY PARA APROXIMAR AS MEDIDAS DO TEMPO DE RESPOSTA DO SENSOR DE 500 mS
  
    leituraUV = analogRead(pinSensorUV); // REALIZA A LEITURA DA PORTA ANALÓGICA 
    indiceUV = map(leituraUV, 0,203,0,10) ; // CONVERTE A FAIXA DE SINAL DO SENSOR DE 0V A 1V PARA O INDICE UV DE 0 A 10.
  
  #ifdef DEBUG
    Serial.print("Indice UV: ");
    Serial.println(indiceUV);
  #endif
}

leituraUV wasn't defined, so code wouldn't compile

try this

#include <LiquidCrystal.h>

LiquidCrystal lcd (8,9,4,5,6,7);

#define pinSensorUV    A5

char s [80];

void setup () {
    Serial.begin (9600);

    lcd.begin (16,2);
    lcd.setCursor (0,0);
    lcd.print ("INDICE ");
    lcd.setCursor (0,1);
    lcd.print ("UV :");
}

void loop ()
{
    int leituraUV = analogRead (pinSensorUV);     // read sensor
    int indiceUV  = map (leituraUV, 0,203,0,10);  // map from 0-10

    lcd.setCursor (8,1);
    lcd.print (indiceUV);

    sprintf (s, "leitura %4d, indice %3d", leituraUV, indiceUV);
    Serial.println (s);

    delay (500); // slow output
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.