Connecting toggle switch to Arduino Uno
Arduino related question goes here: Arduino SE.







simulate this circuit &ndash; Schematic created using CircuitLab

#define switch 3

void setup(){
 pinMode(switch, INPUT_PULLUP);
}

void loop(){
 if(switch == LOW){
  do this;
 } else {
  do that;
 }
}


Edit: