How did I get to this link?

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?

I don't navigate through the arduino site. I use google similar to the term you used:

arduino

Examples:

  1. arduino tutorial switch
  2. arduino playground tlc5940
  3. arduino reference map()

It appears the link "Learning" is actually what leads to the path "tutorial" .

I don't mean to sound rude, but we're you trying to answer the question or just stating your search methods and observations?

I answered by giving how I find pages on arduino.cc.

Then I answered how you would find the tutorials page from the front page.

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.

Home Page: Learning: Switch Case

Crossroads, That doesn't lead to the right page.

Just Google

link:http://arduino.cc/en/Tutorial/switch

Result:

Your search - link:http://arduino.cc/en/Tutorial/switch - did not match any documents.

So, no page leads to it.

Looks that way.

Seems to have been supplanted by info here:

http://www.arduino.cc/playground/Main/InterfacingWithHardware#Switches

Nick Gammon/ Crossroads,

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);
 }
}

Sorry. I should have mentioned the button is momentary.

Something like this (untested):

void loop()
{
  buttonstate = digitalRead(button);
  if (buttonstate == HIGH && previous == LOW)
 {
  digitalWrite(led, ! digitalRead (led));  // toggle LED
  delay (20);  // debounce
 }
 
  previous = buttonstate;  // remember for next time through

}

Thanks Nick, It worked! But I don't understand this line:

digitalWrite(led, ! digitalRead (led));

Okay. I thought it through a bit. This is saying to write to the led the opposite of the current state of the led?

Yes.
Could also write it as:

toggle = 0

then every change:
toggle = 1 - toggle;

so 0, 1-0 = 1, 1-1=0, etc.
Little easier to see, but still same function performed.

lyrical10:
Okay. I thought it through a bit. This is saying to write to the led the opposite of the current state of the led?

Yes, although someone is probably going to point out that whilst this works, it may not always work. Strictly speaking you should write:

if (digitalRead (led) == HIGH)
  digitalWrite(led, LOW);
else
  digitalWrite(led, HIGH);

or:

 digitalWrite(led, digitalRead (led) == HIGH ? LOW : HIGH);

That uses the ternary operator to change HIGH to LOW and vice-versa.