Hello all. I am requesting a little help regaring a code that dosent loop. am i corect in thinking that once an if statment is proved true then it ends?
my code
#include <LiquidCrystal.h> // include LCD library
int val = 0;
int analogPin = 0;
float counter = 0;
float seconds = 0;
// Defenitions
#define BUTTON_ADC_PIN A0 // A0 is the button ADC input
#define LCD_BACKLIGHT_PIN 3 // D3 controls LCD backlight
#define RIGHT_10BIT_ADC 3 // right
#define UP_10BIT_ADC 142 // up
#define DOWN_10BIT_ADC 328 // down
#define LEFT_10BIT_ADC 504 // left
#define SELECT_10BIT_ADC 741 // select
#define LCD_BACKLIGHT_OFF() digitalWrite( LCD_BACKLIGHT_PIN, LOW )
#define LCD_BACKLIGHT_ON() digitalWrite( LCD_BACKLIGHT_PIN, HIGH )
;LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
void setup()
{
pinMode( BUTTON_ADC_PIN, INPUT ); //ensure A0 is an input
digitalWrite( BUTTON_ADC_PIN, LOW ); //ensure pullup is off on A0
digitalWrite( LCD_BACKLIGHT_PIN, HIGH ); //backlight control pin D3 is high (on)
pinMode( LCD_BACKLIGHT_PIN, OUTPUT ); //D3 is an output
//set up the LCD number of columns and rows:
lcd.begin( 16, 2 );
lcd.setCursor( 0, 0 );
lcd.print("Select Time");
lcd.setCursor (0, 1);
lcd.print("Sec:");
lcd.print(counter);
}
void loop()
{
val = analogRead(0);
if (val ==142)
{
seconds = counter +100;
lcd.setCursor(4, 1);
lcd.print(seconds/100);
}
}
I would like to keep pusing the button that gives the analoug value of 142 and keep increesing the counter. any help would be apreciated
Regards; Alex