PlatformIO Community

Keypad not working when built on PIO (same code works on ArduinoIDE)

Hello guys,

Some days ago I ran into a “stranger things” situation here (really :slight_smile: ).
I’m working with an Atmega2560 and the code below runs perfectly when built/sent from ArduinoIDE.
But the same code doesn’t run from PlatformIO.

This stranger behavior started when I updated the Platform Atmel AVR from 1.13 to 1.15 some days ago.
Well, I’ve tried to build the program with 1.12.5 and 1.13 and the problem still.

The code I’m using for testing is very simple, for testing purpose only. The firmware stopped working and the problem was isolated, so this test code.
It’s a Keypad testing interface (4 rows x 3 cols), like this:

Important: The code of Keypad library came from ArduinoIDE folder. So, it’s the same.

When running from PlatformIO: At startup the 2560 detects the ‘4’ key pressed (without really pressed). After that, the program seems to be freeze.
When running from ArduinoIDE: the program starts and keep waiting for some key. When a key is pressed it is printed over serial.

Thank you for any help,


Here is the code:

#include <Key.h>
#include <Keypad.h>

const uint8_t PIN_BUZZER = A8;
const byte ROWS = 4;
const byte COLS = 3;

char keys[4][3] = {

byte row_Pins[4] = {14, 74, 73, 71};  // connect to the row pinouts of the keypad
byte col_Pins[3] = {70, 15, 72};      // connect to the column pinouts of the keypad

ulong _last_eval = 0;

Keypad _keypad(makeKeymap(keys), row_Pins, col_Pins, ROWS, COLS);

void setup() {
  Serial.println("----------------"); // just to see when is starts


void loop() {
  if(millis() > _last_eval) {
    char key = _keypad.getKey();

    if(key != NO_KEY) {
      Serial.print("KEY="); Serial.println(key);
      tone(PIN_BUZZER, 1320, 30); 
    _last_eval = millis()+30;

Nothing jumps out at me in the main code… You could trying adding lib_archive = no to the [env:some_name] block in your platformio.ini to see if that has any effect.

When you tried to use v1.13 of the atmelavr platform again, did you roll back the version manually, or did you use platform = atmelavr@1.13 in your platformio.ini to force the use of that version?

Hi pfeerick,

I did the both two approaches to roll back the version.
Now I will try what you suggested about ‘lib_archive = no’.

Thank you,