Okay. I googled "arduino switch" and found this link: http://arduino.cc/en/Tutorial/switch. But how do I get there from the arduino home screen? If you go to the arduino home page, click the learning link, then examples I don't see switch anywhere.
Is this an old link that shows up on google or am I going crazy?
Okay. Just wanted to make sure you didn't answer the original question: " But how do I get here from the arduino home screen?". Or if it is even possible. Again meaning how would navigate to the page this link brings you to: http://arduino.cc/en/Tutorial/switch ? starting from the home screen.
Thanks for helping me try to find another way to the link.
So what I was looking for was an example of code that would simply allow a button to turn on and off a led, motor, servo, etc. I want the initial state of the connected item to be off. Push the button once it turns on, push it again and it turns off. I have been trying to figure out the simplest code for the job on my own, but can't. I've tried a few different ways with no luck. I could start with the code below to turn on the led but can't figure out how to make the next push turn it off. As you can tell from the simple task I want to perform.... I'm a newbie. Any help would be greatly appreciated.
int button = 6;
int led = 3;
int buttonstate;
int previous = LOW;
void setup()
{
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}
void loop()
{
buttonstate = digitalRead(button);
if (buttonstate == HIGH && previous == LOW)
{
digitalWrite(led, HIGH);
}
}