I need to put a button in my arduino that will pause all code until the button is pressed.
I need to not let the pin in the loop turn on, until a switch is pressed. After that, the switch doesn't matter at all.
Here is my code:
int pin = 9;
int ledPin = 13;
volatile int state = LOW;
volatile int Count = 0;
volatile int Dists = 65;
void setup()
{
pinMode(pin, OUTPUT);
pinMode(ledPin, OUTPUT); // sets the digital pin as output
attachInterrupt(1, Dist, FALLING);
}
void loop()
{
digitalWrite(pin, HIGH);
}
void Dist()
{
Count++;
if (Count >= Dists)
{
digitalWrite(pin, LOW);
digitalWrite(ledPin, HIGH); // sets the LED on
delay(100000);
}
}