Hello,
I've bought an Arduino Nano Evrey and I face some issue when I want to read the state of a push button. That works only on one digital pin (the number 34) and not on the others, so i'm asking myself if the board doesn't work properly or if there is some register to configure.
I know there is intern pull-up, pull-down and maybe I have to play on that but I don't know how and I don't know why that works on only one pin. On some pin by default it seems to be HIGH and others LOW.
Find the schematic here.
Find the pinout schematic:
pinout arduino nano every
Please find the code below (from the example):
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 22; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin// variables will change:
int buttonState = 0; // variable for reading the pushbutton statusvoid setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.println("PRESSED\n");
delay(200);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
Serial.println("RELEASED\n");
delay(200);
}
}
I'm on Debian and I'm using the IDE 1.8.13