I have loaded a code from a YouTube Video lesson #27 from Paul McWhorter and it doesn't work, all I get is LED turns on after upload and won't change with the button being pressed. In the code the LED shouldn't light until the button is pressed, the serial monitor shows the switch responding with 1 or 0 like it should but that is the only part that is working. Could it be the IDE not working or the arduino uno?
int LEDPin = 3;
int buttonPin = 11;
int buttonRead;
int dt = 100;
void setup() {
Serial.begin (9600);
pinMode (LEDPin, OUTPUT);
pinMode (buttonPin, INPUT);
// put your setup code here, to run once:
}
void loop() {
buttonRead = digitalRead(buttonPin);
Serial.println (buttonRead);
delay (100);
if (buttonRead == 1); {
digitalWrite(LEDPin, LOW );
}
if (buttonRead == 0); {
digitalWrite(LEDPin, HIGH);
}
A 10K resistor is connected to 5v, On the Arduino, the other end is connected to pin 11. At pin 11 one side of the switch is wired to pin11, the other side is to ground, when pressed pin 11 will go from 5v to 0v. I have also use a jumper wire to ground to make the voltage drop so I could remove the switch from the circuit to see if it was the problem I end up with the same results LED stays lit and no change when pin 11 goes from 1 to 0 volts.
Some more information, I went on YouTube to the Arduino lesson #27 and followed the tutorial,1st put in the code for the button read, compile and upload was good. The serial monitor shows the switch reading 1 until the button is pushed then reads 0, until released then reads 1 again, so I continued to put the code in to control the LED compile and upload was good, but the LED turned on when it should be off and stays on I even tried other pins for the LED and switch but the same thing happens so I re downloaded the Arduino IDE to make sure it was working same thing happens at this point I think my Arduino uno is faulty because I see the code work in the tutorial but wont work for me.