I have made this If-Then-Else code, but it doesn't work.
First I tough only the analog code is wrong, but if I take a digital port, the code doesn't work either.
What did I do wrong?
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0.00001; // variable to
void setup() {
pinMode(13, OUTPUT); //LED BORD UIT
pinMode(12, OUTPUT); //LED4
pinMode(11, OUTPUT); //LED3
pinMode(10, OUTPUT); //LED2
pinMode(9, OUTPUT); //LED1
pinMode(8, OUTPUT); //Elektro Magneet
pinMode(A0, INPUT);
}
void loop() {
if (A0 == HIGH) {
digitalWrite(13, LOW);
digitalWrite(12, HIGH); //LED on, magnet off
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
} else {
digitalWrite(13, LOW);
digitalWrite(12, LOW); // LED Off, magnet on
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
}
}