Someone fix my code?

the code does not work, someone try to correct it?

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int  sensorPin  =  A0;     // select the input  pin for  the potentiometer 
int  ledPin  =  3;   // select the pin for  the LED
int  sensorValue =  0;  // variable to  store  the value  coming  from  the sensor


void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
if (DEC> 55) {
}

  lcd.print("   >   ..   <   ");
if DEC< 55) {
  lcd.print("   @   ..   @"); 
  }
  }


void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
if (DEC> 30) {
  lcd.print("    ________    ");
if (DEC< 30) {
    lcd.print("    I______I    "); 
  }
  // stampe delle temperature ogni secondo
  delay(100);
}
}

it should be a face on an LCD screen that changes according to the noise around it.

tanks.

Your post was MOVED to its current location as it is more suitable.

what is DEC ?

(answer: have a look here )


if (DEC> 30) {
  lcd.print("    ________    ");
if (DEC< 30) {
    lcd.print("    I______I    "); 
  }
  // stampe delle temperature ogni secondo
  delay(100);
}

Watch your { }


if (DEC> 30) 
{
  lcd.print("    ________    ");

    if (DEC< 30)
       {
          lcd.print("    I______I    "); 
       }
    // stampe delle temperature ogni secondo
    delay(100);
}

Can this every happen ?
if (DEC> 30) . . . if (DEC< 30)

Give us code that compiles.

non sarà mai :nerd_face:

DEC is a constant, it's 10. so the optimizer cleans things up and gets rid of the useless code and the compiled code is this:

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  lcd.begin(16, 2);
  lcd.print("   >   ..   <   ");
}

void loop() {
  lcd.setCursor(0, 1);
}

does not do much, does it?

1 Like

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