Hi, I have an Arduino sketch that is failing when I add simple button.
The first piece of code works as expected, it executes my function over and over until I stop it.
But I only want to call the function when I press the button. If I run the 2nd code snipet it works fine for somewhere between 4 and 8 button pushes then totally hangs the Arduino.
It seems like a hardware issue now that I am experimenting more as I can make the first snipet crash too by pressing the button a bunch of times.
My button is connected to D12 and I'm using the internal Pullup in my setup
pinMode(buttonPin, INPUT_PULLUP);
The only other connection is from the button to GND.
Any ideas? Should I try a different pin? I'm running out of digital pins on my Uno so I may have to use an Analog.
Thanks for any advice.
Phil
buttonState = digitalRead(buttonPin);
printRandomSentance();
delay(100);
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
printRandomSentance();
delay(100);
}
}