I have been trying many variations of code like this, cannot seem to get this to work with how I logically would think it would work. Am I missing something with syntax or breaking some rules? Everything works independently but not jointly.
int switchS = 0;
int var = 1;
void setup() {
pinMode(1,INPUT);
pinMode(7,OUTPUT);
digitalWrite(7,LOW);
}
void loop() {
switchS = digitalRead(1);
while(var == 1)
{
digitalWrite(7,HIGH);
delay(100);
digitalWrite(7,LOW);
delay(100);
if(switchS == HIGH)
{
var = 0;
}
}
delay(5000);
var = 1;
}