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 -
@avmg2502 How is it crashing?
What is the error message?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login