I have an extremely simple program drawing a square on an OLED Display, wired up using SPI (SSD1351) and am Controlling it using the Adafruit Library. This is the code I'm using:
void setup(void) {
Serial.begin(9600);
pinMode(buttonLeft, INPUT_PULLUP);
pinMode(buttonRight, INPUT_PULLUP);
pinMode(buttonUp, INPUT_PULLUP);
pinMode(buttonDown, INPUT_PULLUP);
pinMode(buttonA, INPUT_PULLUP);
pinMode(buttonB, INPUT_PULLUP);
tft.begin();
tft.fillRect(0, 0, 128, 128, RED);
}
int x = 0;
int y = 0;
void loop() {
int left = digitalRead(buttonLeft);
int right = digitalRead(buttonRight);
int up = digitalRead(buttonUp);
int down = digitalRead(buttonDown);
int a = digitalRead(buttonA);
int b = digitalRead(buttonB);
y = y+right-left;
x = x+up-down;
tft.fillRect(x,y,5,5,WHITE);
delay(10);
}
Here's a video of what's happening
They're not quite as visible as in person but they can definitely be seen
I suspect a power supply problem. How is the display powered?
Maybe try a cap across the Vcc & GND pins of the display, on the breadboard. Try a 0.1uF ceramic to start, if that doesn't help, try a larger electrolytic cap eg. 10~100uF.
I don't think it is caused by your code.
Try drawing a black square instead of white. Do you still see the lines?
Adding a 0.1uF/10uF capacitor turned the screen completely black. It's connected to 5v. Funnily enough, when drawing a black square the lines are lighter instead of darker
Yeah I can only attach one image, so I'll attach the one with my... attempt... to connect a 10uF capacitor, before I had it the same just without the capacitor. Also I don't quite know how to make any fancy diagrams so I hope this'll do? I'm using a Teensy 4.0 but also tested it using the Arduino UNO and got the same result.
Yes, that's wrong. You have put the cap in series with the display power pins. It should be in parallel with them.
Connect the wires back the way you had them before. Then connect the cap across the Vcc and GND pins. Make sure you connect the cap the right way around. Electrolytic caps have a + and - pin (ceramic ones don't and can be connected either way).
Soo like this? .. I hope.. but uh the lines still there, unless I already like shorted the cap but I think it should be fine
Also tried it the same way with the ceramic one, but didn't change anything either
The way you connected the capacitor before was incorrect but should not have caused any damage to the cap or the oled.
Sorry my idea did not help.
Did you try the green & blue square suggestion?
My theory is that when white (or black) square is drawn, this increases (or decreases) the power the oled requires to light that row (or maybe column) of pixels. If the required power is not delivered, and the supply voltage drops, then that row of pixels will look dimmer than it should.
But if green or blue square is drawn, this will require a very similar amount of power to the red background colour, so the row of pixels containing the blue or green square will need the same power as a row of pixels containing only red. This may reduce the appearance of the unwanted lines.
You may not want to draw green or blue squares for your project, but this is only a short experiment to confirm my theory about the power supply being the problem.
Smaller, single-colour oled displays only draw 20~30mA, but your oled is larger, has more pixels, and the pixels are RGB, so this display may require significantly more current to run smoothly (without the banding lines) than a small oled.
Just tried this out, using a green background a blue square. The Lines still can be seen at spots where the square has moved although they're not so easy to spot. The Green gets darker in those areas.
That kind-of confirms my theory that there is some power supply problem here. What we do not know is if the problem can be fixed by changing the power supply you are using (using a different supply, changing the wires, adding capacitors etc) or if the power you are supplying is good but the power circuits on the display board itself are not great.
Have you tried replacing the wires which carry power to the oled module? Also try a different USB cable.
I am still convinced this is not caused by your code. Try other test code where objects appear against a coloured background to see if similar lines appear.
A more expensive suggestion would be to buy another similar oled module, from a different vendor, and test that to see if you get the lines with the same code. If not, that would point to the first module being faulty.
I realise these displays cost around £20.
I did find an example that was a little less than £20 on Amazon. I thought the description was quite amusing:
About this item
Resolution: The resolution of this product is 128 * 128, which is very clear.
Touch type: The touch type of this product is non-touch type, which is very convenient to use.
Driver chip: The driver chip of this product is SSD1351, which is very driving.
Good quality: This product is made of high-quality materials, exquisite workmanship, very good quality and long service life.
Low noise: The noise of this product is very small when it is working, and it will not cause additional interference.
I especially liked that non-touch is a very convenient type of touch screen, and that the driver chip is very driving!