I have an Arduino Micro, and I'm trying to get the button example to work.
I'm getting a floating pin for some reason, in the end I disconnected everything, and still getting the same results. The serial monitor is showing a lot of '1's and '0's without anything connected to it, and using the internal pull-up.
What am I doing wrong?
const int pinButton = 2;
int buttonState = 0;
int previousButtonState = HIGH;
void setup() {
Serial.begin(9600);
while (!Serial) ;
delay(1000);
}
void loop() {
buttonState = digitalRead(pinButton);
Serial.println(buttonState);
if (buttonState == HIGH) {
//digitalWrite(LED_BUILTIN, LOW);
} else {
//digitalWrite(LED_BUILTIN, HIGH);
}
}
I was using INPUT_PULLUP, however, I have an Arduino Micro, not UNO.
Is there a similar diagram with which pins are best for pullup in the Micro board?