cancel
Showing results for 
Search instead for 
Did you mean: 

If - else not working

ted korczak
Associate III
Posted on May 03, 2018 at 13:55

Hi

When I press the button Vo is not = vin, no respond to the button at all.

Any suggestions ?

#include <LiquidCrystal.h>

LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);

int analogInput = PB0;

const int ResetPin = PA7;

float vout = 0.0;

float vin = 0.0;

float Vo;

int value = 0;

void setup() {

// pinMode(PB0,analogInput, INPUT);

pinMode(PB0, INPUT_ANALOG);

pinMode(ResetPin, INPUT);

Vo = analogRead(INPUT_ANALOG);

lcd.begin(16, 2);

//lcd.print('DC V');

}

void loop() {

if (digitalRead(ResetPin) == LOW)

{

Vo = vin;

}

else {

// read the value at analog input

value = analogRead(analogInput);

vout = (value * 3.3) / 4200.0;

vin = vout;

if (vin < 0.09)

vin = 0.0; //statement to quash undesired reading !

}

lcd.setCursor(0, 1);

lcd.print('V= ');

lcd.print(vin);

lcd.setCursor(0, 0);

lcd.print('Vo= ');

lcd.print( Vo, 1);

delay(500);

}
0 REPLIES 0