Displaying Images on 4D OLEDS using Arduino
4D Systems makes some really nice serial OLEDS. They aren’t hard to use, but the documentation for them is very scattered. This tutorial pulls together the various pieces i’ve found so that you can get up and running very quickly.
The OLED I worked with was the µOLED-128-GMD. The other OLEDs listed have the same pinouts and as far as i know should work similarly.
I. Slide Show
Start by loading images on the SD card for an OLED slide show. This will serve as a test run to see if the images are on the card properly before you do any coding.
1. Get the images on the Micro SD card.
Download Graphics Composer from the 4d website. http://www.4dsystems.com.au/downloads.php The only version they have is for PCs. You need a microSD to USB adapter so that you can write to the card. The directions to load images with the software come with the zipped sofware file. You can do some minor image editing with the software, but the program is clunky. I suggest cropping and sizing the image in photoshop beforehand. A text file will be created when you upload your pictures. You will need this later for part II so don’t get rid of it.
2. Plug stuff in
Put the SD card in the OLED card slot. Make sure the jumper is connecting both pins on the back. Plug in power (Voltage supply from 3.3V to 6.0V) and Gnd.
3. Show off
Wow everyone with your tiny slide show.
II. Controlling image display with Arduino
1.Download the library
Oscar Gonzalez, the 4d distributor in Spain, wrote up a library with functions that can help you get started.
It’s got these useful functions:
// This will dectect the baudrate
void OLED_Init()// Get 16bits value from RGB (0 to 63, 565 format)
int GetRGB(int red, int green, int blue)// Clears the screen
void OLED_PutPixel(char x, char y, int color)
void OLED_DrawLine(char x1, char y1, char x2, char y2, int color)
void OLED_DrawRectangle(char x, char y, char width, char height, char filled, int color)
void OLED_DrawCircle(char x, char y, char radius, char filled, int color)
// Change font format – FontType can be: OLED_FONT5X7, OLED_FONT8X8, OLED_FONT8X12
void OLED_SetFontSize(char FontType)
void OLED_DrawText(char column, char row, char font_size, char *mytext, int color)
void OLED_DrawSingleChar(char column, char row, char font_size, char MyChar, int color)
Once you’ve downloaded the library, put it in the following path arduino-0010 -> hardware -> libraries. When you start writing your program in arduino, import the OLED library. The library is specifically written for the MicroOLED-160-GMD1module, but works fine with the other modules, except the x parameter on all functions can’t be more than the number of pixels that your 4D_OLED has.
2. Set up the circuit
* Wire the OLED’s TX pin to arduino’s RX pin.
* A 1k resistor should be wired between OLED’s RX pin and arduino’s TX pin.
* Oscar’s library has been setup to use arduino pin 8 as the reset button for the OLED, so wire the ‘R’ pin on the OLED to pin 8 on Arduino.
* Wire power and GND from the breadboard to Arduino.
* Put the OLED jumper on only one pin (so that the two pins are NOT conntected)
4. Examine the text file that was created when you were working with graphics composer.
You will need the sector addresses of each image to be able to call them up using the OLED’s “Display image/Icon from memory card. This will be the last three number in the list that’s give after the height and width.
You will see a string of numbers like “64, 73, 0, 0, 128, 128, 16, 0, 16, 0.” You want are the “0, 16, 0.”
5. Arduino Code
To send out commands serially from Arduino, you’ll use the ‘printByte()’ method as opposed to the Serial.print() method. You’ll be using the OLED’s “Display Image/Icon from Memory Card” command. 4D labels this as an extended command, so a ’40’ hex must be sent before the Display Image command. The following code will load images and then draw on them, resulting in drawing a nose on Tom, a hat on John and earrings on Giana.
We recommend EasyEDA for electronic circuit design.
From Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test
This Post / Project can also be found using search terms:
- hot adulte OLED pic