User Tools

Site Tools


using_pico_with_ssd1306_based_lcd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
using_pico_with_ssd1306_based_lcd [2026/08/16 18:57] – [How the Code Works] walkeradminusing_pico_with_ssd1306_based_lcd [2026/08/19 19:36] (current) – [Something Quirky with this OLED Screen] walkeradmin
Line 58: Line 58:
 \\  \\ 
 \\  \\ 
-{{ :pico-ic2-pins.png?700 |}}+{{ :pico-ic2-pins.png?600 |}}
 \\  \\ 
 There are a sets of I2C0 pins and I2C1 pins, so you need to remember which Bus you are on (zero for our example) You also need to remember the pin numbers as we will reference both the Pin numbers and Bus number is our code. There are a sets of I2C0 pins and I2C1 pins, so you need to remember which Bus you are on (zero for our example) You also need to remember the pin numbers as we will reference both the Pin numbers and Bus number is our code.
Line 71: Line 71:
  
   * Pin 6 = GPIO4 (SDA)   * Pin 6 = GPIO4 (SDA)
-  * Pin 7 = GPIO4 (SCL) +  * Pin 7 = GPIO5 (SCL) 
-\\  +
-\\ +
 ---- ----
 ==== The Micro Python Code ==== ==== The Micro Python Code ====
Line 235: Line 234:
   * lcd.show() - Write to the LCD.   * lcd.show() - Write to the LCD.
  
 +The numbers (0, 0), (0, 16) are the x,y start point of each line of text, we can see that the height of the text we are using is 16 pixels. 
 +\\ 
 +\\ 
 At this point, the LCD will show our text, and you shoud see something very similar to below: At this point, the LCD will show our text, and you shoud see something very similar to below:
 \\  \\ 
 \\  \\ 
 {{ :pico-ssd1306-wiring.png?700 |}} {{ :pico-ssd1306-wiring.png?700 |}}
 +
 +This last part just turns the LCD off after 5 seconds, as I don't know what my LCD is like for burn in.
 +
 +<code:python | download>
 +time.sleep(5)
 +lcd.fill(0)
 +lcd.show()
 +</code>
 +
 +Hopefully, this has worked for you and you can have some fun with the LCD. This example we are only writing text to the LCD, in future examples, we will explore something a little more graphical.
 \\  \\ 
 +\\ 
 +----
 +==== Oh No!!! I don't have an LCD to play with yet!!! ====
 +\\ 
 +Don't worry, I got you. I have set up this project on Wokwi, a simulator site for Microcontrollers. 
 +\\ 
 +\\ 
 +Please follow this link: [[https://wokwi.com/projects/472533833044850689|Example Pico ssd1306 LCD test]]
 +\\ 
 +\\ 
 +Here you can see the code, the library and if you press play it will emulate the actual hardware version we have made.
 +\\ 
 +\\ 
 +{{ :pico-ssd1306-wokwi.png?800 |}}
 +\\ 
 +I hope you find this wiki article useful :)
 +\\ 
 +\\ 
 +----
 +==== Something Quirky with this OLED Screen ====
 +\\ 
 +So I have noticed something a little quirky with this LCD Panel. It seems to be in two parts, let me explain.
 +\\ 
 +\\ 
 +The Yellow section of the panel is 16 pixels high, then there seems to be a hard barrier between there and the Blue section which is 48 pixels high.
 +\\ 
 +\\ 
 +{{ :64x128-oled-screen-split.png?200 |}}
 +\\ 
 +So you can move text vertically up and down the screen, but not through the join in the yellow/blue part, the text will get chopped off. So you will have to think about the screen as two parts. 
 +\\ 
 +\\ 
 +Below is some code where you can squeeze 8 lines of text on to this little OLED. Each line the text is 6 pixels tall, and there is a two pixel gap between each line. Effectively each line takes 8 pixels, so 8 lines = 8linex8Pixel = 64 pixels, the exact LCD height.
  
 +<code:python | download>
 +from machine import Pin, I2C
 +import ssd1306
 +import time
 +
 +i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=200000)
 +lcd = ssd1306.SSD1306_I2C(128, 64, i2c)
 +
 +lcd.fill(0)
 +lcd.text("Yo Tuesday Club!", 0, 0)
 +lcd.text("SSD1306 LCD",      0, 8)
 +lcd.text("Address 0x3C",     0, 16)
 +lcd.text("Cool :)",          0, 24)
 +lcd.text("Another Line :)",  0, 32)
 +lcd.text("One More? :)",     0, 40)
 +lcd.text("Line 7",           0, 48)
 +lcd.text("Line 8",           0, 56)
 +lcd.show()
 +
 +time.sleep(300)
 +lcd.fill(0)
 +lcd.show()
 +</code>
 +
 +The LCD can have 16 characters across, so the characters are 8 pixels wide. So 16char x 8pixel =128 Pixels wide.
 +\\ 
 +\\ 
 +Using the code above, feel free to change the text and have a play, also play with the line spacing to explore the Yellow/Blue section limitation, each line is moved down by 8 pixels in the script, but have a play with these values to see what fits for you.
 +\\ 
 +\\ 
 +----
using_pico_with_ssd1306_based_lcd.1786906645.txt.gz · Last modified: by walkeradmin