my code is using keypad library and oled display. Without the oled code added everything works just fine. as soon as I add code for that, void loop stops working halfway and jump out and call another function at the end. I added several print statements to check this.
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define OLED_WIDTH 128#define OLED_HEIGHT 64
#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);
in setup- works fine until here
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
displayOled(); //welcome screen
setupNewGame();
in loop- works until serial.println(guess) then skips check yourself function , print(result) and play sound to setup newgame. Why not doing while loop? (this part works perfectly fine when oled display was not added)
void loop() {
char guess = 'n';
String result = "miss";
boolean isAlive = true;
while (isAlive){
guess = getGuess();
if (guess != 'n') {
Serial.print("You guessed:");
Serial.println(guess);
delay(500);
result = checkYourself(guess);
Serial.println(result);
playSound(result);
if (result.compareTo("kill") == 0) isAlive = false;
Serial.println("Enter a new guess (1-8):");
}
}
setupNewGame();
}
Is the library causing this? please help thanks