//Controlling Led By slide switch

//Turns on and off a LED ,when slide the switch

//Email:[email protected]

//Website:www.primerobotics.in

const int switchPin = 2; //the switch connect to pin 12

const int ledPin = 3; //the led connect to pin 6

int switchState = 0;         // variable for reading the push button status

void
setup()

{

  pinMode(switchPin, INPUT); //initialize the switchPin as input

  pinMode(ledPin, OUTPUT); //initialize the ledPin as output

}

void
loop()

{

  //read the state of the switch value
  switchState = digitalRead(switchPin);

  if (switchState == HIGH ) //if the state is HIGH

  {

  digitalWrite(ledPin, HIGH); //turn the led on

  }

  else //if the switchPIN is not HIGH (else HIGH)

  {

    digitalWrite(ledPin, LOW); //turn the led off

  }

}
$abcdeabcde151015202530354045505560fghijfghij