Core2 keeps crashing when I try to connect a CardKB module using Arduino IDE
-
Hello, i am having trouble uploading a code to Core2, trying to connect a CardKB module.
Does anyone know how to fix it?#include "Wire.h" #include "Arduino.h" #include "M5GFX.h" #include "M5Unified.h" #define CARDKB_ADDR 0x5F int x=10,y=10; M5GFX display; M5Canvas canvas(&display); void setup() { auto cfg = M5.config(); M5.begin(cfg); Serial.begin(115200); Wire.begin(); pinMode(5, INPUT); digitalWrite(5, HIGH); M5.Lcd.fillScreen(YELLOW); M5.Lcd.setCursor(1, 10); M5.Lcd.setTextColor(YELLOW); M5.Lcd.setTextSize(2); M5.Lcd.printf("IIC Address: 0x5F\n"); M5.Lcd.printf(">>"); } void loop() { Wire.requestFrom(CARDKB_ADDR, 1); while (Wire.available()) { char c = Wire.read(); // receive a byte as characterif if (c != 0) { if(c==180){ //M5.clear(); //x=x-10; M5.Lcd.fillCircle(50, 50, 22, TFT_RED); } if(c==181){ //M5.Display.clear(); y=y-10; M5.Lcd.fillCircle(100, 50, 22, TFT_BLUE); } if(c==182){ //M5.Display.clear(); y=y+10; M5.Lcd.fillCircle(50, 100 , 22, TFT_YELLOW); } if(c==183){ M5.Display.setCursor(0,0); //M5.Lcd.fillScreen(WHITE); delay(1000); M5.update(); x=x+10; M5.Lcd.fillCircle(100, 100, 22, TFT_GREEN); } //M5.Lcd.printf("%c", c); //Serial.println(c, HEX); // M5.Speaker.beep(); } } }
-
@avmg2502
You should debug line by line to see which operation caused it. -
Hello @kuriko
just curious - why are your setting GPIO5 to
input
? This disables the display - is that what you intended?Thanks
Felix