So I’m trying to write this code where someone can enter a number below 1000, and have it be displayed to the serial monitor. I have pushbuttons numbered 0-9, and I am trying to enter 120. So the way I expect it to work would be first displaying 0 (because nothing is being entered, and i is equal to/below 2) but as soon as I start pushing buttons the monitor should display 100, 120, 120. Instead it is displaying 8, 30, 30. I’ve gone over my code a couple of times but I still don’t know where I’ve gone wrong.
const int button0 = 23;
const int button1 = 24;
const int button2 = 27;
const int button3 = 28;
const int button4 = 31;
const int button5 = 32;
const int button6 = 35;
const int button7 = 36;
const int button8 = 39;
const int button9 = 40;
int button0_state = 0;
int button1_state = 0;
int button2_state = 0;
int button3_state = 0;
int button4_state = 0;
int button5_state = 0;
int button6_state = 0;
int button7_state = 0;
int button8_state = 0;
int button9_state = 0;
int lbutton0_state = 0; //Last button state
int lbutton1_state = 0;
int lbutton2_state = 0;
int lbutton3_state = 0;
int lbutton4_state = 0;
int lbutton5_state = 0;
int lbutton6_state = 0;
int lbutton7_state = 0;
int lbutton8_state = 0;
int lbutton9_state = 0;
It's rather hard to concentrate on your code, with all it's screaming for the use of arrays. Sorry, I've got a headache, and I can't listen to all that screaming.