Code getting stuck when select IO pins are set to inputs

Hello! I am trying to configure pins 20 through 27 to be inputs on the Arduino Nano Every. My code is as follows.
All Inputs

This, unfortunately, doesn't work. The code seems to freeze and never gets to the Serial.print() command in the void loop. For whatever reason it seems to get stuck on this chunk of code. I have discovered two ways to successfully get past this block of code. The first way is to comment out pins 22, 23, and 25. When I run the code as follows, it goes through without issue. If I uncomment any of those three lines, it gets stuck.

The second solution, is to set pins 22, 23, and 25 to outputs, instead of inputs. Like such...

I have tried on multiple boards and they both behave in this manner. Why can I not successfully set pins 22, 23, and 25 to inputs? Why do they work as outputs? Why are these pins behaving any differently than the other GPIO pins? Any thoughts welcomed.

There is no Serial.print() in your code. Add one. Problem solved.

2 Likes

A Nano Every only has 22 signal pins as far as I can see. What am I missing?

Please post your code using code tags instead of images.

Pins beyond 21 are not brought out to the edge connector and are reserved.

  PIN2_bp,  // 20 PA2/TWI_SDA
  PIN3_bp,  // 21 PA3/TWI_SCL
  PIN3_bp,  // 22 PC3
  PIN5_bp,  // 23 PA5/NINA TX
  PIN4_bp,  // 24 PA4/NINA RX
  PIN6_bp,  // 25 PD6/LED_BUILTIN
  PIN5_bp,  // 26 PB5/USART3_Rx
  PIN4_bp,  // 27 PB4/USART3_Tx

Looks like 23 and 24 talk to the NINA chip and 25 is the built-in LED.

If I'm reading this table correctly, my understanding is that pins 20-28 can all be used as GPIO. Is there something different you meant by there being only 22 signal pins? This table is right out of the Arduino Nano Every datasheet.

The Serial.print() is further down in the void loop. I did not include that chunk of code because it executes properly when the trouble code is bypassed.

From that table, don't use the first column; use the second column. E.g. entry 23 is D5 and the pin number to use is 5.

For the analogue pins, use the Ax numbers or print those Ax numbers to get the the numbers like 14 (A0 on an Uno).

Ah lovely. This is the type of easy solution I hoped I was overlooking. Thank you so much for the help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.