using_pico_with_ssd1306_based_lcd_and_spi

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_and_spi [2026/08/21 14:13] – [Python Code] walkeradminusing_pico_with_ssd1306_based_lcd_and_spi [2026/08/24 20:01] (current) – [Python Code] walkeradmin
Line 1: Line 1:
 ====== Using Pico with SSD1306 based LCD and SPI ====== ====== Using Pico with SSD1306 based LCD and SPI ======
-<color #ed1c24>***** THIS PAGE IS WORK IN PROGRESS *****</color> 
-\\  
 <color #db5f0b>Aug 2026</color> <color #db5f0b>Aug 2026</color>
 \\  \\ 
Line 52: Line 50:
 So SPI is faster, but there is no addressing, so you cannot chain multiple SPI devices from a single set of Pico GPIO Pins. If you need to run multiple displays, your choice is to either use I2C LCDs, or use multiple sets of SPI pins for each LCD. So SPI is faster, but there is no addressing, so you cannot chain multiple SPI devices from a single set of Pico GPIO Pins. If you need to run multiple displays, your choice is to either use I2C LCDs, or use multiple sets of SPI pins for each LCD.
 \\  \\ 
 +\\ 
 +----
 +==== The Driver for SPI (1306 driver chip) ====
 +\\ 
 +Below is the driver you will need for the LCD. You need to put it in to the <color #ed1c24>lib</color> folder on your Pico.
 +
 +<code:python | download>
 +from machine import Pin, SPI
 +from ssd1306_spi import SSD1306_SPI
 +import time
 +
 +# SPI1 setup
 +spi = SPI(1, baudrate=8000000, polarity=0, phase=0)
 +
 +dc  = Pin(13, Pin.OUT)
 +res = Pin(12, Pin.OUT)
 +cs  = Pin(14, Pin.OUT)
 +
 +oled = SSD1306_SPI(128, 64, spi, dc, res, cs)
 +
 +oled.fill(0)
 +oled.text("Hello Alan!", 0, 0)
 +oled.text("SSD1306 SPI OK", 0, 16)
 +oled.text("Pico 2 Ready", 0, 32)
 +oled.show()
 +
 +# call the function below from your main code with the value 255 (max  brightness)
 +oled.set_brightness(255)
 +</code>
 +\\ 
 +\\ 
 +----
 +==== LCD Test Code ----
 \\  \\ 
 I want to look at the old I2C code and compare to the SPI code to point out some differences, this is the Python code that just prints 8 static lines on the LCD for a simple test. I want to look at the old I2C code and compare to the SPI code to point out some differences, this is the Python code that just prints 8 static lines on the LCD for a simple test.
Line 82: Line 113:
  
 Here is the same code, but modified to run the SPI LCD Screen. Here is the same code, but modified to run the SPI LCD Screen.
 +\\ 
 +<color #ed1c24>Use this code for your SPI LCD Display.</color>
  
 <code:python | download> <code:python | download>
Line 120: Line 153:
   * **In the second example we used the name oled** - oled = SSD1306_SPI(128, 64, spi, dc, res, cs)   * **In the second example we used the name oled** - oled = SSD1306_SPI(128, 64, spi, dc, res, cs)
  
 +The rest is pretty much the same, from a code perspective there really isn't much difference in the amount of work to get the I2C or SPI LCD displays working. 
 +\\  
 +\\  
 +---- 
 +==== The Running LCDs ==== 
 +\\  
 +Below we can see both the I2C LCD (on the right) and the SPI LCD (Below the Pico). 
 +\\  
 +\\  
 +{{ :0.96-spi-lcd-running.jpeg?500 |}} 
 +\\  
 +They both work really well and for simple text based applications will be perfect.  
 +\\  
 +\\  
 +----
using_pico_with_ssd1306_based_lcd_and_spi.1787321614.txt.gz · Last modified: by walkeradmin