I would like to know if this pseudocode works with Analogread()
int volt = A0;
int val = 0;
val = analogread(voltage);
if(val <= 2.5volt){
do something
else
do nothing
I would like to know if this pseudocode works with Analogread()
int volt = A0;
int val = 0;
val = analogread(voltage);
if(val <= 2.5volt){
do something
else
do nothing
almost, you are mixing integer types and floating point types.
try this.
float voltage = (5.0 * analogRead(A0))/1024;
if (voltage <= 2.5)
{
}
else
{
}
Xenia2:
I would like to know if this pseudocode works with Analogread()int volt = A0;
int val = 0;val = analogread(voltage);
if(val <= 2.5volt){
do somethingelse
do nothing
Or just leave it as an int and do int math.
int volt = A0;
int val = 0;
val = analogread(voltage);
if(val <= 512){
do something
else
do nothing
int volt = A0;
int val = 0;
val = analogread(voltage);
But make sure you spell-check it all first.
I would like to know if this pseudocode works
It's pseudo code of course it will not work that is what the pseudo bit means -> pretend.
As a template it works fine, but you don't need the else if you want to do nothing, it will do that by itself.
Yup, I just noticed ![]()
AWOL:
int volt = A0;
int val = 0;
val = analogread(voltage);
But make sure you spell-check it all first.
The following code is monitor the voltage and if the voltage fall within 2.40 - 2.60 its
goes into infinite loop. Under normal operation voltage is approx zero, but sometime
it unexpectly fall within this value, which I do not wanted.
So to fix this, I need to say if voltage fall within 2.40-2.60 for one second then do the
if statement. How do I do it?
float voltage = (5.0 * analogRead(A0))/ 1024;
if (voltage >= 2.40 && voltage <=2.60)
{
while(1)
{
digitalWrite(red, !digitalRead(red));
delay(1000);
}
}
You could look for clues in the blink-without-delay example.
Are you suggesting that I use delay function millis() after analogRead()? I already have a millis() for something else.
you're correct, I should watch what I am saying ![]()