system
January 16, 2015, 10:36pm
1
I've noticed that regardless of which sketch I've loaded onto the Arduino Uno, the Button Pin (2) will ALWAYS cause the LED Pin (13) to go HIGH when pressed. Is this normal?
EDIT: SOLVED: I was confused and thought that the reset button on the board was tied to pin #2 and could be used as a general input.
system
January 16, 2015, 10:41pm
2
Without seeing your code, who can say?
system
January 17, 2015, 1:38am
3
This is the code that I uploaded:
void setup(){}
void loop(){}
After uploading, every time I press the button (pin 2), the LED (pin 13) lights up.
That code is completely empty and does absollutely nothing.
How do you have this button and LED wired up?
system
January 17, 2015, 2:12am
5
I originally uploaded:
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
void setup(){
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin,OUTPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if(buttonState == LOW){
digitalWrite(ledPin, HIGH);
}else{
digitalWrite(ledPin, LOW);
}
}
I subsequently loaded the following sketch successfully:
void setup(){}
void loop(){}
and yet when I press the button (pin 2), the LED (pin 13) lights up.
Was the original sketch never removed or what?
Well, what happens when you upload again? It may not have worked the first time. I sometimes forget if I've pushed the button or not.
Try to upload the blink sketch and see if the LED blinks.
system
January 17, 2015, 3:00am
7
I have uploaded and run several other sketches and in each case, pushing the button causes the LED to light up.
hewlejr:
I originally uploaded:
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
void setup(){
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin,OUTPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if(buttonState == LOW){
digitalWrite(ledPin, HIGH);
}else{
digitalWrite(ledPin, LOW);
}
}
I subsequently loaded the following sketch successfully:
void setup(){}
void loop(){}
and yet when I press the button (pin 2), the LED (pin 13) lights up.
Was the original sketch never removed or what?
Possibly an empty sketch doesn't overwrite what is on the chip. But just keep trying as if something different will happen.
As for the sketch, grounding pin 2 SHOULD cause the pin 13 led to light.
So what is your problem or are you just jerking around?
system
January 19, 2015, 9:51pm
9
It turns out that the microcontroller is actually faulty. I'll be replacing it soon.
hewlejr:
I have uploaded and run several other sketches and in each case, pushing the button causes the LED to light up.
If you upload File->Examples->01. Basics->Blink does the LED blink as well as stay lit whenever the button is pushed?
system
January 20, 2015, 2:57am
11
So. sheepish grin At some point, I was convinced that the reset button on the board was tied to pin #2 and could be used as a general input. Clearly, this is not the case.