Micropython TurnipBit LCD5110 displays English words and phrases

I believe that everyone is very familiar with the Microbit development board. I have sent some small experiments on the Micropython development board before, and most of them use the TPYboard development board. Today, we will use a brand new development board, Turnipbit, for this experiment. The use is similar to that of Turnipbit. It is more suitable for young people to use, and it is more convenient to introduce.

Ready to work

    TurnipBit development kit (board + expansion board) 1 set

     1 Nokia LCD5110 (PCD8544) display

     1 breadboard

     Several Dupont lines

     1 computer with Internet access (requires access to TurnipBit's online programmer)

     Address: http://turnipbit.com/PythonEditor/editor.html

Experimental procedure

     

1. The reference TPYBoard v102 controls the experiments and codes of 5110, and make corresponding modifications. The link is as follows:

     http://docs.tpyboard.com/zh/latest/tpyboard/tutorial/v10x/script/

2. Connect the TurnipBit development board with the expansion board, and the physical connection diagram is as follows:

     The function of the expansion board is to lead out all the pins on the TurnipBit development board, and also classify them, adding 3.3V, 5V and GND pins, which is convenient for everyone to develop and use.

3. Next, connect the lcd5110 display screen to the expansion board accordingly. The wiring diagram is as follows:

  

LCD5110 display

  

TurnipBit Expansion Board

RST

P0

THIS

P1

DC

P5

FROM

P14

CLK

P13

VCC

3.3V

BL

3.3V (normally on, can also be connected to other pins to control on and off through high and low levels)

GND

GND

4. Click on the link: http://turnipbit.com/PythonEditor/editor.html to enter the online programmer of TurnipBit. Enter the code:

   
#************************
# - File Name:turnipbit_lcd5110.py
# - Author:Shandong Radish Electronic Technology Co., Ltd.
# - Date: March 2018 04th
# - Description:RST=>pin0,CE=>pin1,DC=>pin5,DIN=>pin14,CLK=>pin13
#******************* ******

from microbit import *

#ASCII 5x8
font = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x5f\x00\x00\x00\x07\x00\x07\x00\x14\x7f\x14\x7f\x14\x24\x2a\x7f\x2a\x12\x23\x13\x08\x64\x62\x36\x49\x55\x22\x50\x00\x05\x03\x00\x00\x00\x1c\x22\x41\x00\x00\x41\x22\x1c\x00\x14\x08\x3e\x08\x14\x08\x08\x3e\x08\x08\x00\x50\x30\x00\x00\x08\x08\x08\x08\x08\x00\x60\x60\x00\x00\x20\x10\x08\x04\x02\x3e\x51\x49\x45\x3e\x00\x42\x7f\x40\x00\x42\x61\x51\x49\x46\x21\x41\x45\x4b\x31\x18\x14\x12\x7f\x10\x27\x45\x45\x45\x39\x3c\x4a\x49\x49\x30\x01\x71\x09\x05\x03\x36\x49\x49\x49\x36\x06\x49\x49\x29\x1e\x00\x36\x36\x00\x00\x00\x56\x36\x00\x00\x08\x14\x22\x41\x00\x14\x14\x14\x14\x14\x00\x41\x22\x14\x08\x02\x01\x51\x09\x06\x32\x49\x79\x41\x3e\x7e\x11\x11\x11\x7e\x7f\x49\x49\x49\x36\x3e\x41\x41\x41\x22\x7f\x41\x41\x22\x1c\x7f\x49\x49\x49\x41\x7f\x09\x09\x09\x01\x3e\x41\x49\x49\x7a\x7f\x08\x08\x08\x7f\x00\x41\x7f\x41\x00\x20\x40\x41\x3f\x01\x7f\x08\x14\x22\x41\x7f\x40\x40\x40\x40\x7f\x02\x0c\x02\x7f\x7f\x04\x08\x10\x7f\x3e\x41\x41\x41\x3e\x7f\x09\x09\x09\x06\x3e\x41\x51\x21\x5e\x7f\x09\x19\x29\x46\x46\x49\x49\x49\x31\x01\x01\x7f\x01\x01\x3f\x40\x40\x40\x3f\x1f\x20\x40\x20\x1f\x3f\x40\x38\x40\x3f\x63\x14\x08\x14\x63\x07\x08\x70\x08\x07\x61\x51\x49\x45\x43\x00\x7f\x41\x41\x00\x02\x04\x08\x10\x20\x00\x41\x41\x7f\x00\x04\x02\x01\x02\x04\x40\x40\x40\x40\x40\x00\x01\x02\x04\x00\x20\x54\x54\x54\x78\x7f\x48\x44\x44\x38\x38\x44\x44\x44\x20\x38\x44\x44\x48\x7f\x38\x54\x54\x54\x18\x08\x7e\x09\x01\x02\x0c\x52\x52\x52\x3e\x7f\x08\x04\x04\x78\x00\x44\x7d\x40\x00\x20\x40\x44\x3d\x00\x7f\x10\x28\x44\x00\x00\x41\x7f\x40\x00\x7c\x04\x18\x04\x78\x7c\x08\x04\x04\x78\x38\x44\x44\x44\x38\x7c\x14\x14\x14\x08\x08\x14\x14\x18\x7c\x7c\x08\x04\x04\x08\x48\x54\x54\x54\x20\x04\x3f\x44\x40\x20\x3c\x40\x40\x20\x7c\x1c\x20\x40\x20\x1c\x3c\x40\x30\x40\x3c\x44\x28\x10\x28\x44\x0c\x50\x50\x50\x3c\x44\x64\x54\x4c\x44\x00\x08\x36\x41\x00\x00\x00\x7f\x00\x00\x00\x41\x36\x08\x00\x10\x08\x08\x10\x08\x00\x00\x00\x00\x00')

#reset
def reset():
pin0.write_digital(0) # RST on
sleep(0.01)
pin0.write_digital(1) # RST off

def lcd_write(dc,data):
pin5.write_digital(dc)#DC=0 select CMD DC=1 select DATA 
pin1.write_digital(0) #CE=0 open
spi.write(data)
pin1.write_digital(1) #CE=1 close

def lcd_init():
reset()
#初始化配置
data=bytearray(b'\x21\xC8\x06\x13\x0C\x20\x0C')
lcd_write(0,data)
#清屏
data = bytearray(504)
lcd_write(1,data)

#X 0-83
#Y 0-5
#光标位置 指定位置显示字符
def lcd_postion(x,y):
val_x = bytearray()
val_x.append (0x80 + x)
lcd_write(0,val_x)
val_y = bytearray()
val_y.append (0x40 + y)
lcd_write(0,val_y)

def lcd_print_string(message,x,y):
lcd_postion(x,y)
data = bytearray()
for letter in message:
i = (ord(letter) - 32)*5
for b in range (0,5):
data.append(font[i+b])
data.append(0x00)
lcd_write(1, data)

spi.init(baudrate = 328125, sclk = pin13, mosi = pin14)
lcd_init()
lcd_print_string('I am TurnipBit',0,2)


  

5、将TurnipBit通过USB数据线接入电脑,电脑正常显示出[TURNIPBIT]可移动存储设备。点击页面最底部的[下载hex]按钮,目录选择[TURNIPBIT]磁盘,将代码下载到TurnipBit中。

6、等待下载完毕,TurnipBit会自动运行程序。实物效果图:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325310782&siteId=291194637