Hi, I hope someone can help with what is probably a very simple problem......
I have 2 buttons on pins 8,9 with internal pull ups
I have tried to keep things neat by putting my code into different functions.
What I am trying to do is
press button 1 do function A for 5 seconds then return
press button 2 do function B which is a loop reading analog value until you press button 2 again then return
sounds simple but I have tried everything and it either doesnt call the function or repeatedly calls and returns PLEASE help
Latest code using BUTTON library below....(I've cut out the boring bits)
// library code
#include <LiquidCrystal.h>
#include <Button.h>
// button variables
Button button1 = Button(8,PULLUP); // pin assignment
Button button2 = Button(9,PULLUP); // for control buttons
const int i = 1;
void setup() {
// setv up io pins and thermistor variables
}
void loop(){
// set_vent();
temp_read(); //read temperature
Min_Max(); // store the min max bit
check_high(); //check if temperatur is above limits
/* read buttons /
/ press button 1 to display minmax values /
if(button1.isPressed()){
lcd_MinMax();
delay(5000);
}
/ press button 2 to set vent open temperature /
if(button2.isPressed()){
lcd_set_Vent();
}
/ if nothing pressed just display the temperature */
lcd_display(); //display temperature
}
/* functuions to do stuff /
/ function to read temperatures /
/ function to store min max values /
/ function to display min max screen /
/ function to set vent opening using variable resistor /
int lcd_set_Vent(){
while(i==1){ // infinite loop
lcd.clear();
lcd.print("Set Maximum Temp");
lcd.setCursor(0,1); //move down 1
lcd.print(" Max Temp =");
lcd.print(high_temp);
high_temp = map(analogRead(3),0,1023,0,60);// read pot adjust value of high
delay(20);
/ read button /
if(button1.isPressed()){
return 1;
}}
}
/ other functions to do bits */