After some time off, I decided to get back into my project after some help from this topic I started earlier Difference in pinout (types?) Uno/Mega. Unfortunately, even tho I have read multiple times what has been said about the SPI pins on a mega, the displays simply will not work. Both my LED strips and rotary encoder are working, so my code compiles and uploads as it should. The displays are ssd1307 using SPI.
Pinout from MEGA to displays
49 > RST for display1/display2/display3
50 > DC for display1/display2/display3
51 > SDA for display1/display2/display3
52 > SCK for display1/display2/display3
33 > CS for display1
34 > CS for display2
35 > CS for display3
Here is the code I am trying to use:
#include <Adafruit_NeoPixel.h>
#include "HCuOLED.h"
#include "SPI.h"
Adafruit_NeoPixel REVLEDS = Adafruit_NeoPixel(7, 2, NEO_GRB);
Adafruit_NeoPixel DASHLEDS = Adafruit_NeoPixel(3, 3, NEO_GRB);
#define SCK 52
#define SDA 51
#define DC 50
#define RST 49
HCuOLED HCuOLED_5(SSD1307, 33, DC, RST); // For SSD1307 displays (HCMODU0050 & HCMODU0052)
HCuOLED HCuOLED_4(SSD1307, 34, DC, RST); // For SSD1307 displays (HCMODU0050 & HCMODU0052)
HCuOLED HCuOLED_3(SSD1307, 35, DC, RST); // For SSD1307 displays (HCMODU0050 & HCMODU0052)
#define s1 6
#define s2 5
#define key 4
int newCounter = 0;
int oldCounter = 0;
int oldState;
int newState;
int rotated = 0;
int keyState = 0;
int keyReset = 0;
void setup() {
Serial.begin(9600);
REVLEDS.begin();
REVLEDS.setBrightness(25);
DASHLEDS.begin();
DASHLEDS.setBrightness(25);
pinMode(s1, INPUT);
pinMode(s2, INPUT);
oldState = 1;
newState = oldState;
HCuOLED_5.Reset();
pinMode(53, OUTPUT);
}
void loop() {
newState = digitalRead(s1);
if(newState != oldState){
if(digitalRead(s2)!= oldState){
newCounter ++;
} else {
newCounter --;
}
if(newCounter == (oldCounter+2) ||newCounter == (oldCounter-2)){
if(newCounter > oldCounter) rotateRight();
else rotateLeft();
oldCounter = newCounter;
}
}
oldState = newState;
keyState = digitalRead(key);
//Serial.println(keyState);
if(keyState == LOW && keyReset == 0){
onButtonPress();
keyReset = 1;
} else if (keyReset == 1 && keyState == HIGH){
keyReset = 0;
}
for(int i = 0; i < 7; i++){
REVLEDS.setPixelColor(i, 0,255,0);}
REVLEDS.show();
for(int i = 0; i < 3; i++){
DASHLEDS.setPixelColor(i, 0,0,255);}
DASHLEDS.show();
//display 5
HCuOLED_5.SetFont(Terminal_8pt);
HCuOLED_5.Cursor(44,0);
HCuOLED_5.Print("Cpt");
HCuOLED_5.Cursor(20,10);
HCuOLED_5.Print("Fastlane");
}
void onButtonPress(){
Serial.println("Pressed button");
}
void rotateLeft(){
Serial.println("Rotated left");
}
void rotateRight(){
Serial.println("Rotated right");
}
Now the question is, what am I missing? TIA!