Works on Uno, but not on Mega

Hi,

I am having abit of trouble and more than likely not understanding.

I am looking to put an image through the mega, 64*64 in size.

Its a SSD1351 colour OLED.

This code outputs fine on the Uno, but would display anything on the Mega.

//included libraries
#include "SPI.h" //Includes library for SPI communication of display
#include "Adafruit_GFX.h" //Includes core graphics library
#include "Adafruit_SSD1351.h" //Includes hardware specific library

extern const uint16_t smiley48[];

//screen dimensions
#define SCREEN_WIDTH 128 //pixel width
#define SCREEN_HEIGHT 128 //pixel height

//pin definitions
#define SCLK_PIN 13 //defines s clock pin
#define MOSI_PIN 11 //defines master-out slave-in SDA pin
#define RST_PIN   3 //defines reset pin
#define DC_PIN    5 //defines master-in slave-out pin
#define CS_PIN    4 //defines chip select pin

// Colour definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0  
#define WHITE           0xFFFF
#define GREY            0x8410
#define ORANGE          0xE880

Adafruit_SSD1351 display = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);

void setup() {
  display.begin();
  display.fillScreen(BLACK);
}

void loop() {
  display.drawRGBBitmap(0,0,smiley48,64,64);
  delay(1000);
}

#define SCLK_PIN 13 //defines s clock pin
#define MOSI_PIN 11 //defines master-out slave-in SDA pin

These are the wrong pins for SPI on a Mega

I can get the test file to output on the following, but still no image.

#define SCLK_PIN 21
#define MOSI_PIN 20
#define DC_PIN 50
#define CS_PIN 52
#define RST_PIN 48

Post the schematic

Why did you selected these pins?
Look at the manual:

SPI uses the SCK, MOSI, MISO and CS (or SS) pins. Those pins are 52, 51, 50 and 53 (defalut) on a Mega.

I have run it on the 50s and the 20s, but only the SSD1351 test file.
When i try the above code, which works on Uno, no image is displayed.
I dont have any information on the screen except what is supplied here:

Be sure to use the SPI pins that are correct for the MCU you are using. Double check the wiring.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.