My display works fine when only one array (lowercase letters) is used, but once I add about half of the second array (capital letters), my display stops working and it only continues to work in the serial monitor. I thought it might be a power issue (powered with USB from PC), but I can't test any alternatives at the moment.
//This code lets me select any capitalized or lowercase letter and 4 symbols by scrolling through an array with a potentiometer and capitalizing the letter with a button press.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(128,64,&Wire,OLED_RESET);
int potentValRaw = 0; //Potentiometer value raw = 0 - 1023
int potentVal27 = 0; //Potentiometer value 27: (1023/37) = 0 - 27
String displayChar = "";
String letterLow[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",".","-"};
String letterCap[] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",",","_"};
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay(); // clears the screen and buffer
Serial.begin(9600);
}
void loop() {
potentValRaw = analogRead(A7); //Potentiometer pin
potentVal27 = potentValRaw/37; //1023/37 = 0 - 27
if (digitalRead(12) == LOW) displayChar = letterLow[potentVal27]; //Pin 12 is the button pin
if (digitalRead(12) == HIGH) displayChar = letterCap[potentVal27]; //Used to capitalize letters
Serial.println(displayChar);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//Everything above works great in the serial monitor, not so much in the OLED display.
//The weirdest part is that the display works perfectly fine when only one array is used.
//This issue only arises once the second array has about half the capital letters. I'm
//powering this with usb from the PC, so is it a power issue? I can't test it because
//I have no alternative power sources at the moment.
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(64-6,32-12);
display.println(displayChar);
display.display();
}