Hello,
I'm currently trying to get a 0.92" OLED screen to work in one of my projects.
My main program is quite large, so I use another program to test the functionality individually and modify it as needed.
I have a problem with the screen. I can't connect to it from the main program. However, I have no problem to make it work individually when I connect to it with the test program.
I don't understand what's going on. Both programs are the same and yet it doesn't work.
Here is my main program :
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Program : Arduino IDE 2.0.3
// Device : Arduino Nano
// Title : Control of the Kin-Ball electronic scoreboard
// Author : Yannick Blaser
// Created on : 09.01.2023 (DD.MM.YYY)
// Last update :
// Description : This program is used to control the Kin-Ball electronic scoreboard developped by Yannick Blaser.
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// ππππ₯ππ₯π¬π¦
#include <Adafruit_NeoPixel.h> // <β LED strips
#include <Wire.h> // <β
#include <Adafruit_GFX.h> // <βΌ Screen on control panel
#include <Adafruit_SSD1306.h> // <β
#include <EEPROM.h> // <β Points recording
// πππ’πππ π©ππ₯ππππππ¦
// Internal variables
#define RED 0 // Value of RED for the LED strips (0-255)
#define GREEN 0 // Value of green for the LED strips (0-255)
#define BLUE 0 // Value of blue for the LED strips (0-255)
#define WHITE 255 // Value of white for the LED strips (0-255)
#define Brightness 255 // Value of brightness for the LED strips (0-255)
#define LED_COUNT_match 21 // Number of LEDs per match display
#define LED_COUNT_period 14 // Number of LEDs per period display
// Inputs
#define PIN_Button_Left 0 // Digital I/O number of left button <β
#define PIN_Button_Middle 1 // Digital I/O number of middle button <β€
#define PIN_Button_Right 2 // Digital I/O number of right button <βΌ CONTROL PANEL
#define PIN_Button_Back 3 // Digital I/O number of "Cancel" button <β€
#define PIN_Button_Reset 14 // Digital I/O number of "Reset" button <β€
#define PIN_Switch_Match_Period 4 // Digital I/O number of switch <β
// Outputs
#define PIN_Led_Tens_Left 5 // Digital I/O number of match tens points display <β
#define PIN_Led_Unit_Left 6 // Digital I/O number of match units points display <βΌ LEFT DISPLAY
#define PIN_Led_Period_Left 11 // Digital I/O number of period points display <β
#define PIN_Led_Tens_Middle 7 // Digital I/O number of match tens points display <β
#define PIN_Led_Unit_Middle 8 // Digital I/O number of match units points display <βΌ MIDDLE DISPLAY
#define PIN_Led_Period_Middle 12 // Digital I/O number of period points display <β
#define PIN_Led_Tens_Right 9 // Digital I/O number of match tens points display <β
#define PIN_Led_Unit_Right 10 // Digital I/O number of match units points display <βΌ RIGHT DISPLAY
#define PIN_Led_Period_Right 13 // Digital I/O number of period points display <β
// Screen size
#define Screen_Width 128 // OLED display width, in pixels
#define Screen_Height 64 // OLED display height, in pixels
// Variables for points recording
#define Adress_Match_Left 1 // Adress on EEPROM of match points <β¬ LEFT DISPLAY
#define Adress_Period_Left 4 // Adress on EEPROM of period points <β
#define Adress_Match_Middle 2 // Adress on EEPROM of match points <β¬ MIDDLE DISPLAY
#define Adress_Period_Middle 5 // Adress on EEPROM of period points <β
#define Adress_Match_Right 3 // Adress on EEPROM of match points <β¬ RIGHT DISPLAY
#define Adress_Period_Right 6 // Adress on EEPROM of period points <β
// π©ππ₯ππππππ¦ π’π ππππ₯ππ¦π¦ππππ ππππ¦
// Declaration of LED strips
Adafruit_NeoPixel DISPLAY_Match_Tens_Left (LED_COUNT_match, PIN_Led_Tens_Left, NEO_GRBW + NEO_KHZ800); // Declaration of match tens points LED strip <β
Adafruit_NeoPixel DISPLAY_Match_Units_Left (LED_COUNT_match, PIN_Led_Unit_Left, NEO_GRBW + NEO_KHZ800); // Declaration of match units points LED strip <βΌ LEFT DISPLAY
Adafruit_NeoPixel DISPLAY_Period_Left (LED_COUNT_period, PIN_Led_Period_Left, NEO_GRBW + NEO_KHZ800); // Declaration of period points LED strip <β
Adafruit_NeoPixel DISPLAY_Match_Tens_Middle (LED_COUNT_match, PIN_Led_Tens_Middle, NEO_GRBW + NEO_KHZ800); // Declaration of match tens points LED strip <β
Adafruit_NeoPixel DISPLAY_Match_Units_Middle (LED_COUNT_match, PIN_Led_Unit_Middle, NEO_GRBW + NEO_KHZ800); // Declaration of match units points LED strip <βΌ MIDDLE DISPLAY
Adafruit_NeoPixel DISPLAY_Period_Middle (LED_COUNT_period, PIN_Led_Period_Middle, NEO_GRBW + NEO_KHZ800); // Declaration of period points LED strip <β
Adafruit_NeoPixel DISPLAY_Match_Tens_Right (LED_COUNT_match, PIN_Led_Tens_Right, NEO_GRBW + NEO_KHZ800); // Declaration of match tens points LED strip <β
Adafruit_NeoPixel DISPLAY_Match_Units_Right (LED_COUNT_match, PIN_Led_Unit_Right, NEO_GRBW + NEO_KHZ800); // Declaration of match units points LED strip <βΌ RIGHT DISPLAY
Adafruit_NeoPixel DISPLAY_Period_Right (LED_COUNT_period, PIN_Led_Period_Right, NEO_GRBW + NEO_KHZ800); // Declaration of period points LED strip <β
// Color variables for the LED strips
uint32_t COLOR_Match_Tens_Left = DISPLAY_Match_Tens_Left.Color (RED, GREEN, BLUE, WHITE); // Color of match tens points <β
uint32_t COLOR_Match_Units_Left = DISPLAY_Match_Units_Left.Color (RED, GREEN, BLUE, WHITE); // Color of match units points <βΌ LEFT DISPLAY
uint32_t COLOR_Period_Left = DISPLAY_Period_Left.Color (RED, GREEN, BLUE, WHITE); // Color of period points <β
uint32_t COLOR_Match_Tens_Middle = DISPLAY_Match_Tens_Middle.Color (RED, GREEN, BLUE, WHITE); // Color of match tens points <β
uint32_t COLOR_Match_Units_Middle = DISPLAY_Match_Units_Middle.Color (RED, GREEN, BLUE, WHITE); // Color of match units points <βΌ MIDDLE DISPLAY
uint32_t COLOR_Period_Middle = DISPLAY_Period_Middle.Color (RED, GREEN, BLUE, WHITE); // Color of period points <β
uint32_t COLOR_Match_Tens_Right = DISPLAY_Match_Tens_Right.Color (RED, GREEN, BLUE, WHITE); // Color of match tens points <β
uint32_t COLOR_Match_Units_Right = DISPLAY_Match_Units_Right.Color (RED, GREEN, BLUE, WHITE); // Color of match units points <βΌ RIGHT DISPLAY
uint32_t COLOR_Period_Right = DISPLAY_Period_Right.Color (RED, GREEN, BLUE, WHITE); // Color of period points <β
// π©ππ₯ππππππ¦ π’π π¦ππ₯πππ‘
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(Screen_Width, Screen_Height, &Wire, -1);
// π£π₯π’ππ₯ππ π©ππ₯ππππππ¦
// Counters variables
int Counter_Match_Left = 0; // General counter for match points <β
int Counter_Match_Tens_Left = 0; // Counter for match tens points <βΌ LEFT DISPLAY COUNTERS
int Counter_Match_Units_Left = 0; // Counter for match units points <β€
int Counter_Period_Left = 0; // Counter for period points <β
int Counter_Match_Middle = 0; // General counter for match points <β
int Counter_Match_Tens_Middle = 0; // Counter for match tens points <βΌ MIDDLE DISPLAY COUNTERS
int Counter_Match_Units_Middle = 0; // Counter for match units points <β€
int Counter_Period_Middle = 0; // Counter for period points <β
int Counter_Match_Right = 0; // General counter for match points <β
int Counter_Match_Tens_Right = 0; // Counter for match tens points <βΌ RIGHT DISPLAY COUNTERS
int Counter_Match_Units_Right = 0; // Counter for match units points <β€
int Counter_Period_Right = 0; // Counter for period points <β
// Variables for rising edges detection
bool ButtonState_Left; // <β¬ LEFT BUTTON
bool LastButtonState_Left; // <β
bool ButtonState_Middle; // <β¬ MIDDLE BUTTON
bool LastButtonState_Middle; // <β
bool ButtonState_Right; // <β¬ RIGHT BUTTON
bool LastButtonState_Right; // <β
bool ButtonState_Back; // <β¬ CANCEL BUTTON
bool LastButtonState_Back; // <β
bool ButtonState_Reset; // <β¬ RESET BUTTON
bool LastButtonState_Reset; // <β
bool SwitchState; // <β SWITCH
// Variables for blinking
bool Blink_Left = 0; // <β LEFT DISPLAY
bool Blink_Middle = 0; // <β MIDDLE DISPLAY
bool Blink_Right = 0; // <β RIGHT DISPLAY
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void setup() {
//Initialisation of communication with the Arduino
Serial.begin(9600);
// Declaration of pins for inputs and outputs
pinMode(PIN_Button_Left, INPUT);
pinMode(PIN_Button_Middle, INPUT);
pinMode(PIN_Button_Right, INPUT);
pinMode(PIN_Button_Back, INPUT);
pinMode(PIN_Button_Reset, INPUT);
pinMode(PIN_Switch_Match_Period, INPUT);
// π¦ππ₯πππ‘
Serial.println("Tentative de connexion avec l'Γ©cran...");
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)){ // Address 0x3C for 128x64
Serial.println(F("Erreur de communication avec le chipset SSD1306... Arret du programme."));
for(;;);
}
else{
Serial.println(F("Initialisation du controleur SSD1306 reussi."));
}
display.clearDisplay(); // Clearing the screen
display.setTextSize(3); // Setting screen text size
display.setTextColor(WHITE); // Setting screen color
// πππ π¦π§π₯ππ£π¦
// Starting communication with LED strips
DISPLAY_Match_Tens_Left.begin();
DISPLAY_Match_Units_Left.begin();
DISPLAY_Period_Left.begin();
DISPLAY_Match_Tens_Middle.begin();
DISPLAY_Match_Units_Middle.begin();
DISPLAY_Period_Middle.begin();
DISPLAY_Match_Tens_Right.begin();
DISPLAY_Match_Units_Right.begin();
DISPLAY_Period_Right.begin();
// Setting LED strips brightness
DISPLAY_Match_Tens_Left.setBrightness(Brightness);
DISPLAY_Match_Units_Left.setBrightness(Brightness);
DISPLAY_Period_Left.setBrightness(Brightness);
DISPLAY_Match_Tens_Middle.setBrightness(Brightness);
DISPLAY_Match_Units_Middle.setBrightness(Brightness);
DISPLAY_Period_Middle.setBrightness(Brightness);
DISPLAY_Match_Tens_Right.setBrightness(Brightness);
DISPLAY_Match_Units_Right.setBrightness(Brightness);
DISPLAY_Period_Right.setBrightness(Brightness);
// Display current settings on all LED strips
DISPLAY_Match_Tens_Left.show();
DISPLAY_Match_Units_Left.show();
DISPLAY_Period_Left.show();
DISPLAY_Match_Tens_Middle.show();
DISPLAY_Match_Units_Middle.show();
DISPLAY_Period_Middle.show();
DISPLAY_Match_Tens_Right.show();
DISPLAY_Match_Units_Right.show();
DISPLAY_Period_Right.show();
// π£π’ππ‘π§π¦ π₯πππ’π₯πππ‘π
// Clear memory
for (int i = 0; i < EEPROM.length(); i++){
EEPROM.update(i, 0);
}
Serial.println("Memory cleared");
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void loop() {
Serial.println("Starting loop");
// Reading of inputs
ButtonState_Left = digitalRead(PIN_Button_Left);
ButtonState_Middle = digitalRead(PIN_Button_Middle);
ButtonState_Right = digitalRead(PIN_Button_Right);
ButtonState_Back = digitalRead(PIN_Button_Back);
ButtonState_Reset = digitalRead(PIN_Button_Reset);
SwitchState = digitalRead(PIN_Switch_Match_Period);
// ππππ‘ππ π’π π ππ§ππ π£π’ππ‘π§π¦
Serial.println("Match points :");
if (SwitchState == false){
// Increase points for LEFT DISPLAY
if ( (ButtonState_Left != LastButtonState_Left) && (ButtonState_Left == HIGH) && (Counter_Match_Left < 99) ) {
if ( (Blink_Middle == false) && (Blink_Right == false) ){ // If LED strips are currently not blinking, they'll start blinking
Blink_Middle = !Blink_Middle;
Blink_Right = !Blink_Right;
}
else if ( (Blink_Middle == true) && (Blink_Right == true) ){ // If LED strips are currently blinking, they'll stop blinking, the current points will be stored in the memory and then the counter will increase by 1
Blink_Middle = !Blink_Middle;
Blink_Right = !Blink_Right;
EEPROM.update(Adress_Match_Middle, Counter_Match_Middle);
EEPROM.update(Adress_Match_Right, Counter_Match_Right);
Counter_Match_Middle++;
Counter_Match_Right++;
}
}
Serial.println("Left OK,");
// Increase points for MIDDLE DISPLAY
if ( (ButtonState_Middle != LastButtonState_Middle) && (ButtonState_Middle == HIGH) && (Counter_Match_Middle < 99) ) {
if ( (Blink_Right == false) && (Blink_Left == false) ){ // If LED strips are currently not blinking, they'll start blinking
Blink_Right = !Blink_Right;
Blink_Left = !Blink_Left;
}
else if ( (Blink_Right == true) && (Blink_Left == true) ){ // If LED strips are currently blinking, they'll stop blinking, the current points will be stored in the memory and then the counter will increase by 1
Blink_Right = !Blink_Right;
Blink_Left = !Blink_Left;
EEPROM.update(Adress_Match_Right, Counter_Match_Right);
EEPROM.update(Adress_Match_Left, Counter_Match_Left);
Counter_Match_Right++;
Counter_Match_Left++;
}
}
Serial.println("Middle OK,");
// Increase points for RIGHT DISPLAY
if ( (ButtonState_Right != LastButtonState_Right) && (ButtonState_Right == HIGH) && (Counter_Match_Right < 99) ) {
if ( (Blink_Left == false) && (Blink_Middle == false) ){ // If LED strips are currently not blinking, they'll start blinking
Blink_Left = !Blink_Left;
Blink_Middle = !Blink_Middle;
}
else if ( (Blink_Left == true) && (Blink_Middle == true) ){ // If LED strips are currently blinking, they'll stop blinking, the current points will be stored in the memory and then the counter will increase by 1
Blink_Left = !Blink_Left;
Blink_Middle = !Blink_Middle;
EEPROM.update(Adress_Match_Left, Counter_Match_Left);
EEPROM.update(Adress_Match_Middle, Counter_Match_Middle);
Counter_Match_Left++;
Counter_Match_Middle++;
}
}
Serial.println("Right OK,");
// Decrease points
if ( (ButtonState_Back != LastButtonState_Back) && (ButtonState_Back == HIGH) ) {
if ( (Blink_Left == true) || (Blink_Middle == true) || (Blink_Right == true) ){ // If any LED strip is currently blinking, they'll all stop blinking
Blink_Left = !Blink_Left;
Blink_Middle = !Blink_Middle;
Blink_Right = !Blink_Right;
}
else if ( (Blink_Left == false) && (Blink_Middle == false) && (Blink_Right == false) ){ // If all LED strips are currently not blinking, the previous points will be restored form the memory
Counter_Match_Left = EEPROM.read(Adress_Match_Left);
Counter_Match_Middle = EEPROM.read(Adress_Match_Middle);
Counter_Match_Right = EEPROM.read(Adress_Match_Right);
}
}
// Reset points
if ( (ButtonState_Reset != LastButtonState_Reset) && (ButtonState_Reset == HIGH) ) {
Counter_Match_Left = 0;
Counter_Match_Middle = 0;
Counter_Match_Right = 0;
EEPROM.update(Adress_Match_Left, Counter_Match_Left);
EEPROM.update(Adress_Match_Middle, Counter_Match_Middle);
EEPROM.update(Adress_Match_Right, Counter_Match_Right);
}
}
// ππππ‘ππ π’π π£ππ₯ππ’π π£π’ππ‘π§π¦
Serial.println("Period points:");
if (SwitchState == true){
// Increasing points for LEFT DISPLAY
if ( (ButtonState_Left != LastButtonState_Left) && (ButtonState_Left == HIGH) && (Counter_Match_Left < 9) ) { // The current points are stored in the memory and then the counter increase by 1
EEPROM.update(Adress_Period_Left, Counter_Period_Left);
Counter_Period_Left++;
}
Serial.println("Left OK,");
// Increasing points for MIDDLE DISPLAY
if ( (ButtonState_Middle != LastButtonState_Middle) && (ButtonState_Middle == HIGH) && (Counter_Match_Middle < 9) ) { // The current points are stored in the memory and then the counter increase by 1
EEPROM.update(Adress_Period_Middle, Counter_Period_Middle);
Counter_Period_Middle++;
}
Serial.println("Middle OK,");
// Increasing points for RIGHT DISPLAY
if ( (ButtonState_Right != LastButtonState_Right) && (ButtonState_Right == HIGH) && (Counter_Match_Right < 99) ) { // The current points are stored in the memory and then the counter increase by 1
EEPROM.update(Adress_Period_Right, Counter_Period_Right);
Counter_Period_Right++;
}
Serial.println("Right OK,");
// Decrease points
if ( (ButtonState_Back != LastButtonState_Back) && (ButtonState_Back == HIGH) ) {
Counter_Period_Left = EEPROM.read(Adress_Period_Left);
Counter_Period_Middle = EEPROM.read(Adress_Period_Middle);
Counter_Period_Right = EEPROM.read(Adress_Period_Right);
}
// Reset points
if ( (ButtonState_Reset != LastButtonState_Reset) && (ButtonState_Reset == HIGH) ) {
Counter_Period_Left = 0;
Counter_Period_Middle = 0;
Counter_Period_Right = 0;
EEPROM.update(Adress_Period_Left, Counter_Period_Left);
EEPROM.update(Adress_Period_Middle, Counter_Period_Middle);
EEPROM.update(Adress_Period_Right, Counter_Period_Right);
}
}
//πππ¦π£πππ¬ π’π πππ§π & π’π§πππ₯ πππ§ππ’π‘π¦
//Tave the current buttons state as the last state, for next time through the loop
LastButtonState_Left = ButtonState_Left;
LastButtonState_Middle = ButtonState_Middle;
LastButtonState_Right = ButtonState_Right;
LastButtonState_Back = ButtonState_Back;
LastButtonState_Reset = ButtonState_Reset;
// Calculation of the value of each counter
Counter_Match_Tens_Left = Counter_Match_Left/10;
Counter_Match_Units_Left = Counter_Match_Left-(Counter_Match_Tens_Left*10);
Counter_Match_Tens_Middle = Counter_Match_Middle/10;
Counter_Match_Units_Middle = Counter_Match_Middle-(Counter_Match_Tens_Middle*10);
Counter_Match_Tens_Right = Counter_Match_Right/10;
Counter_Match_Units_Right = Counter_Match_Right-(Counter_Match_Tens_Right*10);
// Display of each value on the screen
display.clearDisplay(); // Clearing the screen
display.setTextSize(2);
display.setCursor(0,0);
display.println("N");
display.setCursor(58,0);
display.println("G");
display.setCursor(116,0);
display.println("B");
display.setTextSize(3);
// Left number
display.setCursor(0, 25);
display.println(Counter_Match_Left);
// Middle number // Adjusting the position of the number so that it is centered on the screen
if (Counter_Match_Middle < 10){
display.setCursor(56, 25);
}
else if (Counter_Match_Middle >= 10){
display.setCursor(47, 25);
}
display.println(Counter_Match_Middle);
// Right number // Adjusting the position of the number so that it is aligned to the right of the screen
if (Counter_Match_Right < 10){
display.setCursor(110, 25);
}
else if (Counter_Match_Right >= 10){
display.setCursor(92, 25);
}
display.println(Counter_Match_Right);
display.display();
// Display of each value on the corresponding LED strips
Display_Tens (DISPLAY_Match_Tens_Left, Counter_Match_Tens_Left, COLOR_Match_Tens_Left, Blink_Left);
Display_Units (DISPLAY_Match_Units_Left, Counter_Match_Units_Left, COLOR_Match_Units_Left, Blink_Left);
Display_Units (DISPLAY_Period_Left, Counter_Period_Left, COLOR_Period_Left, false);
Display_Tens (DISPLAY_Match_Tens_Middle, Counter_Match_Tens_Middle, COLOR_Match_Tens_Middle, Blink_Middle);
Display_Units (DISPLAY_Match_Units_Middle, Counter_Match_Units_Middle, COLOR_Match_Units_Middle, Blink_Middle);
Display_Units (DISPLAY_Period_Middle, Counter_Period_Middle, COLOR_Period_Middle, false);
Display_Tens (DISPLAY_Match_Tens_Right, Counter_Match_Tens_Right, COLOR_Match_Tens_Right, Blink_Right);
Display_Units (DISPLAY_Match_Units_Right, Counter_Match_Units_Right, COLOR_Match_Units_Right, false);
Display_Units (DISPLAY_Period_Right, Counter_Period_Right, COLOR_Period_Right, Blink_Right);
DISPLAY_Match_Tens_Left.show();
DISPLAY_Match_Units_Left.show();
DISPLAY_Period_Left.show();
DISPLAY_Match_Tens_Middle.show();
DISPLAY_Match_Units_Middle.show();
DISPLAY_Period_Middle.show();
DISPLAY_Match_Tens_Right.show();
DISPLAY_Match_Units_Right.show();
DISPLAY_Period_Right.show();
Serial.print("Blink state : ");
Serial.print(Blink_Right);
Serial.print(" ");
Serial.print("Counter : ");
Serial.print(Counter_Match_Right);
Serial.print(" ");
Serial.print("Button + state : ");
Serial.print(ButtonState_Right);
Serial.print(" ");
Serial.print("Button - state : ");
Serial.println(ButtonState_Back);
delay(50);
}
And here is my test programm :
#include <Adafruit_NeoPixel.h> // <β LED strips
#include <Wire.h> // <β
#include <Adafruit_GFX.h> // <βΌ Screen on control panel
#include <Adafruit_SSD1306.h> // <β
#include <EEPROM.h> // <β Points recording
#define PIN_Button_Left 16 // Digital I/O number of left button <β
#define PIN_Button_Middle 15 // Digital I/O number of middle button <β€
#define PIN_Button_Right 2 // Digital I/O number of right button <βΌ CONTROL PANEL
#define PIN_Button_Back 3 // Digital I/O number of "Cancel" button <β€
#define PIN_Button_Reset 14 // Digital I/O number of "Reset" button <β€
#define PIN_Switch_Match_Period 4 // Digital I/O number of switch <β
#define Screen_Width 128 // OLED display width, in pixels
#define Screen_Height 64 // OLED display height, in pixels
Adafruit_SSD1306 display(Screen_Width, Screen_Height, &Wire, -1);
bool ButtonState_Left = false; // <β¬ LEFT BUTTON
bool ButtonState_Middle = false; // <β¬ MIDDLE BUTTON
bool ButtonState_Right = false; // <β¬ RIGHT BUTTON
bool ButtonState_Back = false; // <β¬ CANCEL BUTTON
bool ButtonState_Reset = false; // <β¬ RESET BUTTON
bool SwitchState; // <β SWITCH
void setup() {
Serial.begin(9600);
pinMode(PIN_Button_Left, INPUT);
pinMode(PIN_Button_Middle, INPUT);
pinMode(PIN_Button_Right, INPUT);
pinMode(PIN_Button_Back, INPUT);
pinMode(PIN_Button_Reset, INPUT);
pinMode(PIN_Switch_Match_Period, INPUT);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)){ // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay(); // Clearing the screen
display.setTextSize(3); // Setting screen text size
display.setTextColor(WHITE); // Setting screen color
}
void loop() {
ButtonState_Left = digitalRead(PIN_Button_Left);
ButtonState_Middle = digitalRead(PIN_Button_Middle);
ButtonState_Right = digitalRead(PIN_Button_Right);
ButtonState_Back = digitalRead(PIN_Button_Back);
ButtonState_Reset = digitalRead(PIN_Button_Reset);
SwitchState = digitalRead(PIN_Switch_Match_Period);
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,0);
display.println("N");
display.setCursor(58,0);
display.println("G");
display.setCursor(116,0);
display.println("B");
display.setTextSize(3);
display.setCursor(0,16);
display.println(ButtonState_Right);
display.setCursor(56,16);
display.println(ButtonState_Middle);
display.setCursor(110,16);
display.println(ButtonState_Left);
display.setCursor(0,40);
display.println(SwitchState);
display.setCursor(56,40);
display.println(ButtonState_Back);
display.setCursor(110,40);
display.println(ButtonState_Reset);
display.display();
}
Does anyone have any idea what might be causing this problem?