ted
June 6, 2018, 2:47am
1
Hi
I want to print letter A when voltage is between 2 and 4 volts.
Thanks for help
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
pinMode(PA7, INPUT_ANALOG);
lcd.begin(16, 2);
}
void loop() {
float volt = analogRead(PA7);
volt = (volt * 3.3) / 4095.0;
lcd.setCursor(0,0);
lcd.print(volt);
lcd.setCursor(10,0);
lcd.print( ???);
delay(100);
}
if(volt <= 4 && volt >= 2)
{
lcd.print (A); //print letter A
}
else
{
??? // print nothing
}
ted
June 6, 2018, 2:57am
3
I did, but there is more to do, I marked that by - ?
ted
June 6, 2018, 3:15am
7
I have a error
simple_DC_voltmeter:22: error: expected unqualified-id before '{' token
{
void loop() {
float volt = analogRead(PA7);
volt = (volt * 3.3) / 4095.0;
lcd.setCursor(0,0);
lcd.print(volt);
lcd.setCursor(10,0);
lcd.print( "A");
delay(100);
}
if(volt <= 4 && volt >= 2);
{
lcd.print ("A"); //print letter A
}
ted
June 6, 2018, 3:24am
9
The letter - A - stays all the time
void loop() {
float volt = analogRead(A0);
volt = (volt * 3.3) / 4095.0;
lcd.setCursor(0,0);
lcd.print(volt);
lcd.setCursor(10,0);
//lcd.print ( "A");
delay(100);
if(volt <= 4 && volt >= 2);
lcd.print ("A"); //print letter A
}
if(volt <= 4 && volt >= 2);
Remove the semicolon from the end of this line.
ted
June 6, 2018, 3:33am
14
Delta_G:
void loop() { //////<<<<<< OPENING BRACE
float volt = analogRead(PA7);
volt = (volt * 3.3) / 4095.0;
lcd.setCursor(0,0);
lcd.print(volt);
lcd.setCursor(10,0);
lcd.print( "A");
delay(100);
} //////////// <<<<<<<<<<CLOSING BRACE
if(volt <= 4 && volt >= 2);
{
lcd.print ("A"); //print letter A
}
Check your braces. Your loop function ends right after the delay(100) line. After that the if statement isn't inside any function and that's illegal code. That's the source of your error.
for this the error is
simple_DC_voltmeter:21: error: expected unqualified-id before 'if'
if(volt <= 4 && volt >= 2);
^
simple_DC_voltmeter:22: error: expected unqualified-id before '{' token
{
ted
June 6, 2018, 3:36am
16
void loop() { //////<<<<<< OPENING BRACE
float volt = analogRead(PA7);
volt = (volt * 3.3) / 4095.0;
lcd.setCursor(0,0);
lcd.print(volt);
lcd.setCursor(10,0);
lcd.print( "A");
delay(100);
} //////////// <<<<<<<<<<CLOSING BRACE
if(volt <= 4 && volt >= 2)
{
lcd.print ("A"); //print letter A
}
error
simple_DC_voltmeter:21: error: expected unqualified-id before 'if'
if(volt <= 4 && volt >= 2)
Wawa
June 6, 2018, 3:43am
18
volt = (volt * 3.3) / 4095.0;
An Uno is a 5volt Arduino, and has a 10-bit A/D.
float volt = analogRead(A0) * 5.0 / 1024;
Leo..
ted
June 6, 2018, 3:44am
19
No errors, on LCD two " AA", all the time, below 2V and above 2V
void loop() { //////<<<<<< OPENING BRACE
float volt = analogRead(PA7);
volt = (volt * 3.3) / 4095.0;
lcd.setCursor(0,0);
lcd.print(volt);
lcd.setCursor(10,0);
lcd.print( "A");
delay(100);
//////////// <<<<<<<<<<CLOSING BRACE
if(volt <= 3 && volt >= 2)
{
lcd.print ("A"); //print letter A
}
}
ted
June 6, 2018, 3:50am
21
Wawa:
volt = (volt * 3.3) / 4095.0;
An Uno is a 5volt Arduino, and has a 10-bit A/D.
float volt = analogRead(A0) * 5.0 / 1024;
Leo..
Actually I am using STM32 for testing, for Voltmeter only pins names are different.
Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Tom...
ted
June 6, 2018, 4:00am
25
This is working, but I have to use reset button, to clear last reading. A is coming up when voltage is above 2V and is says when voltage is below 2V
void loop() { //////<<<<<< OPENING BRACE
float volt = analogRead(PA7);
volt = (volt * 3.3) / 4095.0;
lcd.setCursor(0,0);
lcd.print(volt);
lcd.setCursor(10,0);
//lcd.print ( "A");
delay(100);
//////////// <<<<<<<<<<CLOSING BRACE
if(volt <= 3 && volt >= 2)
{
lcd.print ("A"); //print letter A
}
}
ted
June 6, 2018, 4:05am
26
Delta_G:
So you were lying here?
Are you just trying to aggravate people and waste people's time? Why are you lying? I'm done. You can figure this out on your own and maybe next time you can learn to tell the truth and not lead people down the wrong path trying to answer your question.
Sorry for that,I am not lying. I have explain what I'm doing.
ted
June 6, 2018, 4:10am
29
This circuit but with STM32
ted
June 6, 2018, 4:13am
30
Delta_G:
No, You were lying. You said it was an UNO when it clearly was not. Why?
There will be 1 page of explanations to prove that Uno and STM32 can use the same programs in 80%