how to program a impulse switch?

Hi

i'm trying to use my arduino control some diferent things, and then i need a way of programming one output to turn on when i press the switch, and off with the next press...

can anybody help me?

btw: i'm trying to learn the arduino programming language, but it's hard :stuck_out_tongue:

There is a button library that can help. Create a boolean variable, initialized to false. Each time the button is pressed, set the value of the boolean variable to not what it currently is. Turn the light on when the value is true, and off when it is false.

bool LedOn = false;
#define ledPin 13
#define buttonPin 2

void loop()
{
   if(digitalRead(buttonPin) == HIGH)
   {
      ledOn = !ledOn;
   }

   if(ledOn)
   {
      digitalWrite(ledPin, HIGH);
   }
   else
   {
      digitalWrite(ledPin, LOW);
   }
}

You'd need to add code to this to debounce the button, or use the library.