Beginner, using an Uno with a 1602 LCD Keypad shield. The original sketch does Serial print fine, I thought I could just add lcd.begin and lcd.print.
I'm also having trouble how to properly post a sketch I used </> but don't know where to use ' and why.
I have this sketch that I have started to modify to print to LCD screen. I get this error message,
C:\Users\Lamon\Documents\Arduino\LM35_Test\LM35_Test.ino:8:8: error: expected initializer before '.' token
int lcd.begin;
^
C:\Users\Lamon\Documents\Arduino\LM35_Test\LM35_Test.ino: In function 'void loop()':
C:\Users\Lamon\Documents\Arduino\LM35_Test\LM35_Test.ino:35:3: error: 'lcd' was not declared in this scope
lcd.begin(16, 2);
^~~
exit status 1
Compilation error: expected initializer before '.' token
/* LM35 analog temperature sensor with Arduino example code. More info: https://www.makerguides.com */
I don't know what I need to add to correct this.
// Define to which pin of the Arduino the output of the LM35 is connected:
#define sensorPin A5
int fahrenheit;
int celsius;
int lcd.begin;
void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
lcd.begin;
}
void loop() {
// Get a reading from the temperature sensor:
int reading = analogRead(sensorPin);
//fahrenheit = ((celsius * 9) / 5 + 32);
// Convert the reading into voltage:
float voltage = reading * (5000 / 1024.0);
// Convert the voltage into the temperature in degree Celsius:
float tempC = voltage / 10;
float temperature = ((tempC * 9) / 5 + 32); // Convert to fahrenheit
// Print the temperature in the Serial Monitor:
//Serial.print(temperature);
//Serial.print(" \xC2\xB0"); // shows degree symbol
//Serial.println("F");
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
delay(1000); // wait a second between readings
}
