Hi everyone, so I am making this project and I have used every single I/O pin except D0,1,12. Since 0 and 1 are for RX and TX I am not gonna use them. I have decided to use the analogue pins as my digital inputs and one digital output(I need 3 buttons and 1 led for indication).
So I did this to the code:
const int MemwriteLOW = A0; //button to A0 to write the LOW value in the EEPROM
const int MemwriteHIGH = A1; //button to A1 to write the HIGH value in the EEPROM
const int MemwriteCLR = A2; //button to A2 to clear the values in the EEPROM
const int MemwriteBLINK = A3; //LED to A3 to indicate memory write in EEPROM
byte MemwriteLOWstate = 0;
byte MemwriteHIGHstate = 0;
byte MemwriteCLRstate = 0;
void setup() {
pinMode(MemwriteLOW, INPUT); //button low as input
pinMode(MemwriteHIGH, INPUT); //button low as input
pinMode(MemwriteCLR, INPUT); //button low as input
pinMode(MemwriteBLINK, OUTPUT); //led as output
}
So the problem is here. This should work but it doesn't. I have a small part of the code which checks if the button is pressed and overall that part works everywhere except with the analogue pins. The led pin is working like a charm, but A0 and A1 do nothing, and A3 if pressed does the code for A2 and if pressed for a longer period it does its own code.
Here is the sample code for the buttons(its the same for the three it just has different values):
MemwriteLOWstate = digitalRead(MemwriteLOW);
if (MemwriteLOWstate == HIGH) {
WriteStuffLOW(encoder0Pos);
digitalWrite(MemwriteBLINK, HIGH);
delay(300);
digitalWrite(MemwriteBLINK, LOW);
delay(300);
}
Does anyone know why I am getting this weird behavior?