- Sat Jan 13, 2018 10:52 pm
#197885
OK here is the stripped down version of my program without the volt meter code or the push button code to implement or decrement the float variable and no lcd code to see the variables changing in value.
The 3 push buttons in the code are only there to initiate a save of one the 3 variables to the eeprom. And as you can see whenever any one of the push buttons are pressed the code goes into a while loop for de-bouncing and that variable is only saved once for whatever button is pressed in the void loop.
Pretty simple, press a button and that variable is saved. Definitely not complicated...
Thanks
jessey
As far as what I've read and understand about arduino is it's not only for professionals and students but
also for hobbyists who don't have any or not too much comprehension of the inner workings of arduino of which I
am definitely one. So please excuse me if I'm ignorant of arduino as I'm looking to understand.
The 3 push buttons in the code are only there to initiate a save of one the 3 variables to the eeprom. And as you can see whenever any one of the push buttons are pressed the code goes into a while loop for de-bouncing and that variable is only saved once for whatever button is pressed in the void loop.
Pretty simple, press a button and that variable is saved. Definitely not complicated...
Thanks
jessey
As far as what I've read and understand about arduino is it's not only for professionals and students but
also for hobbyists who don't have any or not too much comprehension of the inner workings of arduino of which I
am definitely one. So please excuse me if I'm ignorant of arduino as I'm looking to understand.
Code: Select all
#include <EEPROM.h>
float Volt_Set_Point=1.234;
int a;
int b;
int Button_1 = 5;
int Button_2 = 6;
int Button_3 = A1;
#define Is_Pressed 0
void setup() {
pinMode(Button_1, INPUT); // on pin 5
pinMode(Button_2, INPUT); // on pin 6
pinMode(Button_3, INPUT); // on pin A1
eeprom_read_block((void*)&Volt_Set_Point, (void*)0, sizeof(float));// uses memory locations 0, 1, 2 and 3
eeprom_read_block((void*)&a, (void*)4, sizeof(int));// uses memory locations 4 and 5
eeprom_read_block((void*)&b, (void*)6, sizeof(int));// uses memory locations 6 and 7
}// end of the void setup()
void loop() {
if (digitalRead(Button_1)==Is_Pressed)
{
while (digitalRead(Button_1)==Is_Pressed)
{delay(100);}// debounce
eeprom_write_block((const void*)&Volt_Set_Point, (void*)0, sizeof(float));
}
if (digitalRead(Button_2)==Is_Pressed)
{
while (digitalRead(Button_1)==Is_Pressed)
{delay(100);}// debounce
eeprom_write_block((const void*)&a, (void*)4, sizeof(int));
}
if (digitalRead(Button_2)==Is_Pressed)
{
while (digitalRead(Button_1)==Is_Pressed)
{delay(100);}// debounce
eeprom_write_block((const void*)&b, (void*)6, sizeof(int));
}
}// end of the void loop()