Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Ashok R
Published © CC BY-NC-ND

Getting Start with Raspberry Pi Pico

Getting start with Raspberry Pi Pico and OLED Display

BeginnerShowcase (no instructions)1 hour1,786
Getting Start with Raspberry Pi Pico

Things used in this project

Hardware components

Raspberry Pi Pico
Raspberry Pi Pico
×1

Software apps and online services

Thonny Python IDE

Story

Read more

Schematics

Schematic

Code

main.py

MicroPython
# Code with Pico by Ashok (www.ashokr.com) for www.embedded.club
from machine import Pin, Timer, I2C
from ssd1306 import SSD1306_I2C
import framebuf
#import utime

logo = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x3F,
        0x3F, 0xBF, 0x3F, 0xBF, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F,
        0x3F, 0x3F, 0x1F, 0x3F, 0xBF, 0x3F, 0x3F, 0x3F, 0x7F, 0x7F,
        0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
        0x1F, 0x1F, 0x1F, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x1F,
        0x1F, 0x1F, 0x1F, 0x3F, 0x3F, 0xFF, 0xFF, 0x1F, 0x1F, 0x1F,
        0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF,
        0x7F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x9F,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xF0, 0x80, 0x0E, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xEF, 0xEF, 0xDF, 0x9F, 0xBF, 0x7F, 0x7E, 0xFE, 0xF8, 0x01,
        0x07, 0x03, 0x71, 0xFC, 0xFE, 0x7E, 0x3F, 0xBF, 0xDF, 0xFF,
        0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x08, 0x80,
        0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
        0xC3, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFE, 0xFC, 0xF1, 0x73, 0x27, 0x8F, 0x8F, 0xDF, 0xDF,
        0xDF, 0x4F, 0x0F, 0x07, 0xC2, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0,
        0xE0, 0xC0, 0xC0, 0x86, 0x0F, 0xCF, 0xCF, 0xDF, 0xDF, 0x8F,
        0x8F, 0x0F, 0x27, 0x73, 0xF9, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFC, 0xF8, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xFF,
        0xFF, 0xFE, 0xFC, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF8, 0xF8,
        0xFC, 0xFF, 0xFF, 0xF8, 0xF8, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9,
        0xF9, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF9,
        0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F,
        0x01, 0x3C, 0x1E, 0x1F, 0x0F, 0x87, 0xC3, 0xE3, 0xF1, 0xF0,
        0xF0, 0xF3, 0xF7, 0xE7, 0xC7, 0x0F, 0x0F, 0x0F, 0x8F, 0xE7,
        0xE7, 0xF7, 0xF1, 0xF0, 0xF1, 0xF3, 0xE7, 0xCF, 0x8F, 0x1F,
        0x3E, 0x38, 0x00, 0x03, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x01, 0x03,
        0x7F, 0xFF, 0x1F, 0x01, 0x81, 0x01, 0x01, 0x1F, 0xFF, 0x3F,
        0x03, 0x01, 0xF1, 0xFF, 0x01, 0x01, 0x01, 0xFF, 0xF9, 0xF9,
        0xF9, 0x01, 0x01, 0xF9, 0xF9, 0xF9, 0xFF, 0x01, 0x01, 0x01,
        0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x01, 0x01, 0x01, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0x8F, 0x01, 0xF8, 0xFE, 0xFF, 0xFF, 0x1E,
        0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0x7F, 0x1F, 0x00, 0x00, 0x00, 0x0F, 0x3F, 0x7F, 0x7F,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3E, 0x00, 0x3E,
        0xFF, 0xFF, 0xFE, 0xF8, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xE0, 0xC0, 0x81,
        0xC0, 0xF0, 0xFF, 0xFF, 0xE0, 0xC0, 0x81, 0xC0, 0xE0, 0xFE,
        0xFF, 0xFF, 0xC0, 0x80, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0x80,
        0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0xC0, 0xFE, 0xFE,
        0xFE, 0xFE, 0xFE, 0x80, 0x80, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFC, 0xF8, 0x83, 0x03, 0xF1, 0xF8, 0xF8, 0xF8,
        0xF8, 0xF0, 0xE0, 0xC1, 0x81, 0x01, 0x01, 0xF8, 0xFE, 0xFE,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0x00,
        0x01, 0xC1, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFC, 0xFD, 0x03,
        0x03, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x8F, 0xCF, 0xCF, 0xCF,
        0x8F, 0x8F, 0x1F, 0x1F, 0xFF, 0x0F, 0x0F, 0x0F, 0xFF, 0xFF,
        0x3F, 0x1F, 0x8F, 0x8F, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xDF,
        0xFF, 0x3F, 0x1F, 0x0F, 0x8F, 0x8F, 0xCF, 0x8F, 0x8F, 0x0F,
        0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xE3, 0xC7, 0xCF, 0x9F, 0x9F,
        0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x80, 0xC1, 0xC3, 0xC7, 0xE7,
        0xE7, 0xE7, 0xE7, 0xE7, 0xC3, 0xC1, 0x80, 0x00, 0x1F, 0x1F,
        0x1F, 0x1F, 0x9F, 0xDF, 0xCF, 0xE7, 0xF3, 0xF8, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0x00, 0x00, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE3,
        0xF0, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
        0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
        0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x80,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
        0xFE, 0xFC, 0xFC, 0xF9, 0xF3, 0xF3, 0xF7, 0xE7, 0xE7, 0xE7,
        0xE7, 0xF3, 0xF3, 0xF9, 0xF8, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFC, 0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC,
        0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC,
        0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF]

WIDTH = 128
HEIGHT = 64

i2c = I2C(0) # SCL=Pin(GP9), SDA=Pin(GP8) 

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)
print("OLED Display Initilized")

oled.fill(0)
#oled.text("Rasp Pi Pico",1,1)

#oled.show()
oled.draw_image(logo)

led1 = Pin(25, Pin.OUT)
timer1 = Timer()
def tick_timer(timer):
    global led1
    led1.toggle()
    
timer1.init(freq=2,mode=Timer.PERIODIC,callback=tick_timer)

Credits

Ashok R
37 projects • 102 followers
Hobbyist/Engineer/Director/Animatior

Comments