I am a new programmer and maker, and as I was making this "simple" project, I ran into an issue. I don't know why it is not working so can someone maybe look through the code and my Arduino setup. Thanks
Code:
int ledPin = 12;
int buttonPin = 8;
Well that seems to be an important detail that I left out XD. Basically, the LED is supposed to be on while I hold the button, but the LED just doesn't turn on. Thanks for the fast response by the way =p
Do you understand how the tactile switches function? You should only use 2 pins (diagonal corners) to get the effect you are looking for. Pin 8 should go to your resistor and one pin of the switch, and the other side of the resistor goes to ground (pulldown). The opposite corner pin of the switch goes to 5V. Sometimes the pins of the switch don't fit in a breadboard well, so check that too.
The LED works in the configuration you suggested, but I think it might be the way I am wiring the pushbutton. I also think that the code may have some errors.
tinman13kup:
Do you understand how the tactile switches function? You should only use 2 pins (diagonal corners) to get the effect you are looking for. Pin 8 should go to your resistor and one pin of the switch, and the other side of the resistor goes to ground (pulldown). The opposite corner pin of the switch goes to 5V. Sometimes the pins of the switch don't fit in a breadboard well, so check that too.
I don't understand what you mean by "Pin 8 should go to your resistor and one pin of the switch, and the other side of the resistor goes to ground (pulldown)." Do you want me to lead a wire from pin 8 to a resistor and from the resistor to the switch? If so, then I don't see what you mean by the second part of the suggestion "other side of the resistor goes to ground". Thanks for the help anyways
ok never mind I figured out the solution. I took tinman13kup 's suggestion and finally got the button to power the LED like I wanted it to. thanks for the help everyone =p