Click here to Skip to main content
15,888,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is the code :

/*
  LiquidCrystal Library - Hello World

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)


*/

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

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//intialise all varibales being used in the program
float currentTemp = tempsensor();
int ledPin = 13; // choose the pin for the LED
int inPin = 7;   // choose the input pin (for a pushbutton)
int val = 0;     // variable for reading the pin status
digitalWrite(LED, HIGH);
 digitalWrite(LED, LOW);
void setup() {

  pinMode(ledPin, OUTPUT);  // declare LED as output
  pinMode(inPin, INPUT);    // declare pushbutton as input
  
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
}

void loop() {
  
  val = digitalRead(inPin);  // read input value
  if (val == HIGH) {         // check if the input is HIGH (button released)
  float currentTemp = tempsensor();
  if(currentTemp<maxTemp){
  //turn the heat up(LED )
   digitalWrite(LED, HIGH);
   }else if(currentTemp>maxTemp){
    //turn off heat(LED)
    digitalWrite(LED, LOW);
     }else{}
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(maxTemp);
}
}


Here are the errors:


ArduinoLcdButtonFunctions:71: error: 'tempsensor' was not declared in this scope

   float currentTemp = tempsensor();

                                  ^

ArduinoLcdButtonFunctions:72: error: 'maxTemp' was not declared in this scope

   if(currentTemp<maxTemp){

                  ^

ArduinoLcdButtonFunctions:74: error: 'LED' was not declared in this scope

    digitalWrite(LED, HIGH);

                 ^

ArduinoLcdButtonFunctions:77: error: 'LED' was not declared in this scope

     digitalWrite(LED, LOW);

                  ^

ArduinoLcdButtonFunctions:83: error: 'maxTemp' was not declared in this scope

   lcd.print(maxTemp);

             ^

exit status 1
'tempsensor' was not declared in this scope



What can I do to fix this ???

What I have tried:

Ardiuno Forums, Youtube, StackOverFlow forums.
Posted
Updated 20-Jan-19 7:14am

All of these messages are self-explanatory, and are telling you that you are trying to use references that have not been defined. I suggest you go to Arduino - Home[^] and study more of the samples.
 
Share this answer
 
You must learn the basic of the language and that is the scope of a variable. It means that the compiler [doesn't] know which variable is to use. It cant guess!!!

Read and understand that scope tutorial. Read also some other lessons of it to improve your knowledge.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900