Hello guys,
Some days ago I ran into a “stranger things” situation here (really ).
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: https://www.amazon.com/Universal-Solder-Arduino-Raspberry-Tactile-Plastic/dp/B07B2LRKXV
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,
MarceloZanette
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] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
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.begin(9600);
Serial.println("----------------"); // just to see when is starts
pinMode(PIN_BUZZER, OUTPUT);
}
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;
}
}