int LEDPin=6;
int buttonPin=12;
int buttonRead;
int dt=100;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LEDPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
buttonRead=digitalRead(buttonPin);
Serial.println(buttonRead);
delay(dt);
if(buttonRead==1){
digitalWrite(LEDPin, LOW);
}
if(buttonRead==0){
digitalWrite(LEDPin, HIGH);
}
}
Hello guys,
I have got a problem with my pushbutton circuit.
I have got an Arduino Uno, all connected, in the right port.
I wanted to create a circuit which will turn the LED on as I push the button, but there is a problem. My serial monitor only reads 1, when I push the button it does not show 0 and the LED does not turn on. I’m pretty sure that I got all of it connected it the right way, the right pins etc. I have tried all of the cables that I used in this circuit by connecting them to the resistor to LED and 5V and they were good. I used 10k ohms resistor, which seems to be working because I attached LED to it and it worked. I also tried replacing the pushbuttons, but none of the 4 that I have worked. Please help.
I also attach the picture of my breadboard.
Have a nice day