Using a small OLED I2C display with the Arduino Uno
Today I decided I wanted to figure out how to use a small OLED display that I have, with an Arduino Uno. I also partially followed this instructables article.
So first I did some searching to figure out how I would go about connecting the display to the board. I found out that I would have to use a breadboard and some wires, as its pin orientation doesn't allow it to directly connect to the board. So with some additional searching, I found I had to connect the SCL pin on the display to the A5 pin on the board, and the SDA to A4, then VCC and GND to the appropriate 5V and Ground pins.
Then, I plugged in the board to my computer and used the code found here to make a quick sketch in the Arduino IDE to use as an I2C scanner to find the I2C address of the display.
Now having found the address to be 0x3C, the next step was to install the necessary libraries.
https://github.com/adafruit/Adafruit_SSD1306 (SSD1306 library)
https://github.com/adafruit/Adafruit-GFX-Library (GFX library)
After downloading the libraries, and placing them in the Arduino libraries folder, I opened up an example file and put in the I2C address for my board to see if it would work. However when trying to upload it, I got the following error.
So I went into that header file, and found that the height in the header was defined to be 32 instead of 64, so to change it I commented out that specific line (line 74), and un-commented the one above it, as they are seemingly placed conveniently to be able to change between screen sizes easily.
Now the program was able to be uploaded onto the board, and produced the following result using the example code downloaded with the library.
via GIPHY
Next, I am going to look through some code and potentially find a guide online so that I can create some designs of my own on this display.
Also, as this display has more individual light nodes than the LED shield that I have used previously, there's more room to do cool things. One thing in particular that I would love to recreate is Conway's Game of Life, although I do not yet know if that is possible here, as it requires constant changing of the bitmaps, rather than fixed sets.
So first I did some searching to figure out how I would go about connecting the display to the board. I found out that I would have to use a breadboard and some wires, as its pin orientation doesn't allow it to directly connect to the board. So with some additional searching, I found I had to connect the SCL pin on the display to the A5 pin on the board, and the SDA to A4, then VCC and GND to the appropriate 5V and Ground pins.
Then, I plugged in the board to my computer and used the code found here to make a quick sketch in the Arduino IDE to use as an I2C scanner to find the I2C address of the display.
Now having found the address to be 0x3C, the next step was to install the necessary libraries.
https://github.com/adafruit/Adafruit_SSD1306 (SSD1306 library)
https://github.com/adafruit/Adafruit-GFX-Library (GFX library)
After downloading the libraries, and placing them in the Arduino libraries folder, I opened up an example file and put in the I2C address for my board to see if it would work. However when trying to upload it, I got the following error.
So I went into that header file, and found that the height in the header was defined to be 32 instead of 64, so to change it I commented out that specific line (line 74), and un-commented the one above it, as they are seemingly placed conveniently to be able to change between screen sizes easily.
Now the program was able to be uploaded onto the board, and produced the following result using the example code downloaded with the library.
via GIPHY
Next, I am going to look through some code and potentially find a guide online so that I can create some designs of my own on this display.
Also, as this display has more individual light nodes than the LED shield that I have used previously, there's more room to do cool things. One thing in particular that I would love to recreate is Conway's Game of Life, although I do not yet know if that is possible here, as it requires constant changing of the bitmaps, rather than fixed sets.
Looks great! This should work well for the Game of Life. I can help with programming suggestions for how to update the bitmap after you compute the contents of each generation.
ReplyDelete