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);

in setup:

display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
//welcome screen  (sorry I have to add at least 7 character to edit)
//stops here and crashes everything

void loop() { 
  char guess = 'n';
  String result = "miss";
  boolean isAlive = true;
  while (isAlive){
    guess = getGuess();
    if (guess != 'n') {    
      Serial.print("You guessed:");

      result = checkYourself(guess);
      if (result.compareTo("kill") == 0) isAlive = false;
      Serial.println("Enter a new guess (1-8):");     

Is the library causing this? please help thanks

  • 1
    You should correctly format the code in your question. Renove the backtics around it. Then select the code and click the {} button in the question editor – chrisl Nov 7 at 22:44
  • 1
    Also include a complete minimal example, not only parts of the code. If the complete code is too large, you should create a smaller code, that also shows your problem. How do you know, that it is skipping setupNewGame()? You don't print outside of the while loop – chrisl Nov 7 at 22:48
  • adding the display oled function just stopped the setup and loop working. – Rhea Ramtohul Nov 8 at 0:35
  • void displayOled() { 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(); } – Rhea Ramtohul Nov 8 at 0:35
  • 1
    please do not put code in comments .... any new information needs to be part of the question ... use the edit button to add your code – jsotola Nov 8 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.