Digital Text Art Patterns With Micropython

by abdullahatrandom235 in Circuits > Raspberry Pi

106 Views, 3 Favorites, 0 Comments

Digital Text Art Patterns With Micropython

A es+.png

Recently I saw the text contest and thought it was really intresting I chose to do digital art and display my initials a.s as ascii art with word patterns I am going to use some inexpensive items you can find them on amazon or in ali express. What are you waiting for lets jump right in.

Supplies

wires.png
pico.png
breadboard.png
lcd.png
lcd2.png

You will need:

jumper wires

oled lcd

raspberry pi pico you will see two options in the link pico wh and h choose h

breadboard

Wiring and Downloading Ssd1306 Libaries

awe.png
tools.png
manage packages.png
Screenshot from 2024-06-12 15-54-57.png

We will first wire the pico and lcd. Connect pin 36 or 3v3 out of the pico to vcc of the lcd, next connect pin 38 of or gnd of the pico to the ground of the lcd now connect gp0 to the sda of the lcd now connect gp1 to the scl of the lcd now the wiring should be done note however if the wiring is improper or is not connected properly the program will give you an eio time out. Now we have to download libaries to do this go to tools, then click manage packages now go to the search and search ssd1306 you should see micropython-ssd1306 click on it and press install.

Importing Libraries

program1.png

In this step we will import libraries if you already haven't done so please install the ssd1306 libary without it you cannot do this step now you can import libaries we need to import machine, import ssd1306, and import time now it should look like this.

import machine
import ssd1306
import time

Now we need to setup the display program sin were using gp1 for scl and gp0 for sda it should look like this:

i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))

Now we need to know the height and width of the display, the width is 128 and the height is 64 so now the code should look like this:

# OLED display setup
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)

Now were done importing the libaries and setting up the lcd here is the code up to date:

import machine
import ssd1306
import time
import urandom


# OLED display setup
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)

The Loop

program.png

Now we are going to add the loop. The loop is so that the whole program repeats itself forever instead of stop at the end usually loops in python are a conditional but we will be using infinite looping with while true so we don't have to set how many loops we want it to run for the loop. Now we add while true to the statement like this

import machine
import ssd1306
import time
import urandom


# OLED display setup
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
while True:

Finishing the Program

program3.png
awsomer0.png
a.png
dot.png
s.png

Now to finish off we are going to add the text so for the first line add the text like this:

 oled.fill(0)
 oled.text("awesomeawesomeaw",1,0,2)
 oled.text("amazingamazingam",1,10,2)
 oled.text("coolcoolcoolcool",1,20,2)
 oled.text("awesomeawesomeaw",1,30,2)
 oled.text("coolcoolcoolcool",1,40,2)
 oled.text("amazingamazingam",1,50,2)
 oled.text("awesomeawesomeaw",1,60,2)
 oled.show()
 time.sleep(1)

This is going to display the word pattern on the oled in this case awesome, amazing and cool now we finish off my adding more texts to loop or repeat over and over

 oled.fill(0)
 oled.text("awesomeawesomeaw",1,0,2)
 oled.text("amazingamazingam",1,10,2)
 oled.text("coolcoolcoolcool",1,20,2)
 oled.text("awesomeawesomeaw",1,30,2)
 oled.text("coolcoolcoolcool",1,40,2)
 oled.text("amazingamazingam",1,50,2)
 oled.text("awesomeawesomeaw",1,60,2)
 oled.show()
 time.sleep(1)
 oled.fill(0)
 oled.text("awesome  esomeaw",1,0,2)
 oled.text("amazin /\ azinga",1,10,2)
 oled.text("coolc /  \ lcool",1,20,2)
 oled.text("awes / /\ \ meaw",1,30,2)
 oled.text("coo / ____ \ ool",1,40,2)
 oled.text("am /_/    \_\ am",1,50,2)
 oled.text("aw            aw",1,60,2)
 oled.show()
 time.sleep(1)
 oled.fill(0)
 oled.text("awesomeawesomeaw",1,0,2)
 oled.text("amazingamazingam",1,10,2)
 oled.text("coolcoolcoolcool",1,20,2)
 oled.text("awesom __ esomea",1,30,2)
 oled.text("coolc (__) lcool",1,40,2)
 oled.text("amazi     zingam",1,50,2)
 oled.text("awesomeawesomeaw",1,60,2)
 oled.show()
 time.sleep(1)
 oled.fill(0)
 oled.text("awesomeawesomeaw",1,0,2)
 oled.text("amazi ___ amazin",1,10,2)
 oled.text("cool / __| coolc",1,20,2)
 oled.text("awes \__ \ omeaw",1,30,2)
 oled.text("cool |___/ lcool",1,40,2)
 oled.text("amazi     zingam",1,50,2)
 oled.text("awesomeawesomeaw",1,60,2)
 oled.show()
 time.sleep(1)

Ok now here is the whole code:

import machine
import ssd1306
import time
import urandom


# OLED display setup
i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
while True:
 oled.fill(0)
 oled.text("awesomeawesomeaw",1,0,2)
 oled.text("amazingamazingam",1,10,2)
 oled.text("coolcoolcoolcool",1,20,2)
 oled.text("awesomeawesomeaw",1,30,2)
 oled.text("coolcoolcoolcool",1,40,2)
 oled.text("amazingamazingam",1,50,2)
 oled.text("awesomeawesomeaw",1,60,2)
 oled.show()
 time.sleep(1)
 oled.fill(0)
 oled.text("awesome  esomeaw",1,0,2)
 oled.text("amazin /\ azinga",1,10,2)
 oled.text("coolc /  \ lcool",1,20,2)
 oled.text("awes / /\ \ meaw",1,30,2)
 oled.text("coo / ____ \ ool",1,40,2)
 oled.text("am /_/    \_\ am",1,50,2)
 oled.text("aw            aw",1,60,2)
 oled.show()
 time.sleep(1)
 oled.fill(0)
 oled.text("awesomeawesomeaw",1,0,2)
 oled.text("amazingamazingam",1,10,2)
 oled.text("coolcoolcoolcool",1,20,2)
 oled.text("awesom __ esomea",1,30,2)
 oled.text("coolc (__) lcool",1,40,2)
 oled.text("amazi     zingam",1,50,2)
 oled.text("awesomeawesomeaw",1,60,2)
 oled.show()
 time.sleep(1)
 oled.fill(0)
 oled.text("awesomeawesomeaw",1,0,2)
 oled.text("amazi ___ amazin",1,10,2)
 oled.text("cool / __| coolc",1,20,2)
 oled.text("awes \__ \ omeaw",1,30,2)
 oled.text("cool |___/ lcool",1,40,2)
 oled.text("amazi     zingam",1,50,2)
 oled.text("awesomeawesomeaw",1,60,2)
 oled.show()
 time.sleep(1)

Ok now save it as main.py in pico's folder now run it you should see the pattern followed by a iembeded in the pattern followed by a dot followed by the s.

Why I Chose A.s

I choose a.s mainly for my code and for the art because it is my initials it is also the initials of my other siblings which is why its special. You can make your own ascii art with the word or letter that is special to you.

Awesome, Cool and Amazing?

Why I choose the pattern awesome cool and amazing, because this project was awesome cool and amazing if you like it and enjoyed it please favorite this instructable and if you have an comments or concerns feel free to comment below.