my code is using keypad library and oled display and piezo element. Without the oled code added everything works just fine. as soon as I add code for that, sound stops working. doesn't even call the display oled(). 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);
void setup(){
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
displayOled(); //welcome screen //stops here and crashes everything setupNewGame();
}
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);
result = checkYourself(guess);
Serial.println(result);
playSound(result);
if (result.compareTo("kill") == 0) isAlive = false;
Serial.println("Enter a new guess (1-8):");
}
}
setupNewGame();
}
my display OLEd function:
void displayOled() {
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(20, 0);
display.println("WELCOME");
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 17);
display.println("PressENTER");
display.setCursor(0, 35);
display.println("to start!");
display.display();
}
Is the library causing this? please help thanks