PKE Project. No Sound, OLED & Image Issue

I am having a couple of issues with a project I am trying to follow from github.

I am using as the OP suggests, and Arduino Nano, but I can only load it by using the old bootloader in the software, so I am not sure if that might be causing any issue. Just an FYI.

First, I cant seem to get any sound from the buzzer. The OP doesn't specify any specific buzzer but in his breadboard image he does show a 2 pin, I don't have a 2 pin but I have used a 3 pin module KY-006.

Second, The Image and animation is distorted on the OLED. The OP says Adafruit_SSD1306 display in the code, but in his readme file he mentions Diymall 0.96". I have a Kuman KY34 0.96" 128x64.

I am also having an input issue with button 1. It doesnt seem to be communicating as its input is not recognized.

Please see pics and Video link

MrBullSTR:
I am having a couple of issues with a project I am trying to follow from github.
GitHub - CountDeMonet/Arduino_PKE_Meter: Code and models for an arduino based Ghostbusters PKE Meter

I am using as the OP suggests, and Arduino Nano, but I can only load it by using the old bootloader in the software, so I am not sure if that might be causing any issue. Just an FYI.

Not a problem. Many Nanos come with the old bootloader (especially from China) and you just have to know/learn this and then make the correct selection in the IDE

First, I cant seem to get any sound from the buzzer. The OP doesn't specify any specific buzzer but in his breadboard image he does show a 2 pin, I don't have a 2 pin but I have used a 3 pin module KY-006.

The middle pin doesn't need to be connected and it should work just fine as long as it is wired up correctly.

Second, The Image and animation is distorted on the OLED. The OP says Adafruit_SSD1306 display in the code, but in his readme file he mentions Diymall 0.96". I have a Kuman KY34 0.96" 128x64.

the SSD1306 is just the chip that is driving the display. Many (most) of the OLED screens use this

I am also having an input issue with button 1. It doesnt seem to be communicating as its input is not recognized.

Need to see a schematic to know...

And adding your code would also be helpful

Hello and Thanks for the response.
You cleared up a lot of misunderstandings especially with the chip.
Journey of discovery.
With a little bit of work, I now have sound.
I was powering the unit through a USB powered Voltage Regulator which I guess was not putting out enough mA.
I hooked up a 9V through a Voltage Regulator 7805 to power the project. This fixed the sound problem. So I now have enough mA.
Please see my youtube video for demonstration.

Now all the issue is, that I cannot see the bottom of the screen completely and the words as chopped off (See Video)

Here is the Sketch I am using;

#include <Servo.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

Servo SERVO1;

int LEDNum = 0; // current LED that is lit
unsigned long previousMillis; // will store last time LED was updated

const int LED1 = 12;
const int LED2 = 11;
const int LED3 = 10;
const int LED4 = 9;
const int LED5 = 8;
const int LED6 = 7;
const int LED7 = 6;

int FILM;
bool SOUND;

const int GB1_PATTERN[7] = {
LED3, LED5, LED7, LED4, LED1, LED6, LED2
};
const int GB2_PATTERN[7] = {
LED3, LED1, LED6, LED4, LED7, LED5, LED2
};

const int DISPLAY_PATTERN[][2] = {
{21, 5},
{18, 20},
{15, 30},
{12, 45},
{9, 50},
{6, 55},
{3, 65}
};

const int BUZZER = 5;
const int BUTTON1 = 3;
const int BUTTON2 = 4;

// know thy button state
bool medium_state = false;
bool high_state = false;
bool button1_down = false;
bool button2_down = false;

void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(LED7, OUTPUT);
pinMode(BUZZER, OUTPUT);
pinMode(BUTTON1, INPUT);
pinMode(BUTTON2, INPUT);

digitalWrite(BUTTON1, HIGH);
digitalWrite(BUTTON2, HIGH);

// The following lines are because my PKE setup
// is currently running without the buck converter.
// Pin D2 acts as VCC for the OLED screen
// PN June 12, 2018d
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();

// Clear the buffer.
display.clearDisplay();
initialSetup();

SERVO1.attach(13);
SERVO1.write(90);
}

// current display val
int currentVal = 0;
void loop() {
int button1 = digitalRead(BUTTON1);
int button2 = digitalRead(BUTTON2);

if ( button1 == LOW && button1_down == false ) {
button1_down = true;

if ( medium_state == true) {
medium_state = false;
high_state = false;
currentVal = 0;
} else {
medium_state = true;
high_state = false;
currentVal = 40;
}
} else {
if (button1 == HIGH && button1_down == true ) {
button1_down = false;
}
}

if ( button2 == LOW && button2_down == false ) {
button2_down = true;

if (high_state == true) {
medium_state = false;
high_state = false;
currentVal = 0;
} else {
medium_state = false;
high_state = true;
currentVal = 90;
}
} else {
if (button2 == HIGH && button2_down == true ) {
button2_down = false;
}
}

// do the led stuff
LEDLoop(currentVal);

// do the servo stuff
ServoLoop(currentVal);

// delay in between reads for stability
delay(1);
}

void initialSetup(){
String headings[] = {"WHICH PATTERN?", "SOUNDS?"};
String labels[][2] = {
{"GB1", "GB2"},
{"NO", "YES"}
};
for (int i = 0; i < 2; i++){
int button1 = digitalRead(BUTTON1);
int button2 = digitalRead(BUTTON2);
while (button1 == HIGH && button2 == HIGH){
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(22, 5);
display.print(headings*);*

  • display.setCursor(10, 30);*
    _ display.print(labels*[0]);_
    _
    display.setCursor(100, 30);_
    _ display.print(labels[1]);
    display.display();
    button1 = digitalRead(BUTTON1);
    button2 = digitalRead(BUTTON2);
    }
    if (button1 == LOW && i == 0){
    FILM = 1;
    } else if (button2 == LOW && i == 0){
    FILM = 2;
    } else if (button1 == LOW && i == 1) {
    SOUND = false;
    } else if (button2 == LOW && i == 1) {
    SOUND = true;
    }
    digitalWrite(BUTTON1, HIGH);
    digitalWrite(BUTTON2, HIGH);
    delay(500);
    display.clearDisplay();
    }
    }
    int prevB = 0;
    void drawDisplay(int level, int bar) {
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(29, 5);_
    //String display_str = String("GHOSTBUSTERS");
    //display.print(display_str);
    _ int b1 = random(prevB, bar);
    int b2 = random(prevB, bar);
    int b3 = random(prevB, bar);
    int b4 = random(prevB, bar);
    int b5 = random(prevB / 2, bar / 2);
    int b6 = random(prevB / 2, bar / 2);
    prevB = bar;
    display.fillRect(2, display.height() - (5 + b1), 5, b1, WHITE);
    display.fillRect(10, display.height() - (5 + b2), 5, b2, WHITE);
    display.fillRect(18, display.height() - (5 + b5), 5, b5, WHITE);
    display.fillRect(display.width() - 23, display.height() - (5 + b6), 5, b6, WHITE);
    display.fillRect(display.width() - 15, display.height() - (5 + b4), 5, b4, WHITE);
    display.fillRect(display.width() - 7, display.height() - (5 + b3), 5, b3, WHITE);
    display.drawCircle(display.width() / 2, display.height() / 2 + 7, level, WHITE);
    display.display();
    }
    void clearLoop() {
    display.clearDisplay();
    prevB = 0;
    }
    void LEDLoop(int convertedVal) {
    unsigned long ledSpeed = map(convertedVal, 0, 100, 500, 20);
    // check to see if it's time to change the state of the LED*
    * unsigned long currentMillis = millis();
    if ((unsigned long)(currentMillis - previousMillis) >= ledSpeed)
    {
    previousMillis = millis();
    if (SOUND) {
    TriggerBuzzer();
    }
    if (FILM == 1){
    if (LEDNum == 0){
    clearLoop();_
    digitalWrite(GB1_PATTERN[6], LOW);
    _ } else {_
    digitalWrite(GB1_PATTERN[LEDNum - 1], LOW);
    _ }_
    digitalWrite(GB1_PATTERN[LEDNum], HIGH);
    _ } else {
    if (LEDNum == 0){
    clearLoop();_
    digitalWrite(GB2_PATTERN[6], LOW);
    _ } else {_
    digitalWrite(GB2_PATTERN[LEDNum - 1], LOW);
    _ }_
    digitalWrite(GB2_PATTERN[LEDNum], HIGH);
    _ }_
    drawDisplay(DISPLAY_PATTERN[LEDNum][0], DISPLAY_PATTERN[LEDNum][1]);
    _ LEDNum = (LEDNum + 1) % 7;
    }
    }
    void TriggerBuzzer() {
    tone(BUZZER, 2000); // Send 2KHz sound signal...
    delay(20); // ...for 20 msec*
    * noTone(BUZZER);
    }
    void ServoLoop(int convertedVal) {
    int servoVal = map(convertedVal, 0, 100, 110, 40);
    SERVO1.write(servoVal);
    }*_

Journey of Discovery Complete.

Thanks to "Crazy Couple" on Youtube and their OLED video.

The issue was within the Adafruit_SSD1306.h (Header File).
The settings were for the 128x32 OLED
(#ifndef Adafruit_SSD1306_H
#define Adafruit_SSD1306_H

// ONE of the following three lines must be #defined:
#define SSD1306_128_64 ///< DEPRECTAED: old way to specify 128x64 screen
//#define SSD1306_128_32 ///< DEPRECATED: old way to specify 128x32 screen

Once I defined the SSD1306 as 128_64 Saved the header file and then reloaded my sketch to the Nano it all works perfect as it should.

Please visit my youtube video for final example. PKE Meter Ghostbusters Arduino - YouTube

I hope my journey helps someone else out.

Rather than edit library header files. You should declare your OLED using the newer constructor methods. The one you are using is depricated

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Look at the examples in the Adafruit_SSD1306 library.