Just got my first UNO board today. Following the instructions in the book but I can't make the button work on the LED. The light just stays on. Any help for a first timer?
Ok.
First: Next time you have to write a topic that has every information in it (look at over ones).
So did you follow all instructions that are over the actual programme?
The circuit:
-
LED attached from pin 13 to ground
-
pushbutton attached to pin 2 from +5V
-
10K resistor attached to pin 2 from ground
-
Note: on most Arduinos there is already an LED on the board
attached to pin 13.
If you are not sure with the programme here is the example again:
created 2005
by DojoDave http://www.0j0.org
modified 17 Jun 2009
by Tom Igoe
*/
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Copy it in to a new sketch an upload it.
And if all this didn“t help watch this there are every intstructions step for step explained:
Also don't forget to use the code tags when posting code, helps keep the formatting right and makes it easy to read
//like this
void loop(){
doStuff();
}
//etc
but I can't make the button work on the LED.
Is that the button on the board?
If so that is a reset button and not one yu can use in your sketch.
Mike, Why not? it looks like a N.O. momentary contact tactile push button switch switch, just like a reset switch. Think it will reset? might, the light be right?
Doc
Why not? it looks like a N.O. momentary contact tactile push button switch switch
Because on the board it is attached to the reset pin, not a pin you can read.
Grumpy_Mike:
Why not? it looks like a N.O. momentary contact tactile push button switch switch
Because on the board it is attached to the reset pin, not a pin you can read.
Not strictly true... At the risk of confusing a noob, I'd just like to point out that on the '328P the reset pin is multiplexed with RC6, and that it is (theoretically) possible to disable the reset functionality and use it as an input pin using purely software methods. However, that would break the bootloader as it needs a reset to kick it off - you'd have to implement some other way of starting the bootloader to compensate, or you'd never be able to upload a sketch again.