[英]My raspberry pi pico gives me a strange error
So I want to turn on a lcd 16x2 using my Raspberry Pi Pico but it can't detect the file requested.所以我想使用我的 Raspberry Pi Pico 打开 lcd 16x2,但它无法检测到请求的文件。 First, I upload the file with首先,我上传文件
import machine
import utime
rs= machine.Pin(16,machine.Pin.OUT)
e = machine.Pin(17,machine.Pin.OUT)
d4 = machine.Pin(18,machine.Pin.OUT)
d5 = machine.Pin(19,machine.Pin.OUT)
d6 = machine.Pin(20,machine.Pin.OUT)
d7 = machine.Pin(21,machine.Pin.OUT)
def setCursor(line, pos):
b = 0
if line==1:
b=0
elif line==2:
b=40
returnHome()
for i in range(0, b+pos):
moveCursorRight()
def clearScreen():
rs.value(0)
send2LCD8(0b00000001)#clear screen
longDelay(2)#clear screen needs a long delay
rs.value(1)
def setupLCD():
rs.value(0)
send2LCD4(0b0011)
send2LCD4(0b0011)
send2LCD4(0b0011)
send2LCD4(0b0010)
send2LCD8(0b00101000)
send2LCD8(0b00001100)#lcd on, blink off, cursor off.
send2LCD8(0b00000110)#increment cursor, no display shift
send2LCD8(0b00000001)#clear screen
longDelay(2)#clear screen needs a long delay
rs.value(1)
def displayString(row, col, input_string):
setCursor(row,col)
for x in input_string:
send2LCD8(ord(x))
longDelay(10)
Then, I rename it lcd_pico.py And in the main.py file, I write然后,我将它重命名为 lcd_pico.py 在 main.py 文件中,我写
from lcd_pico import *
setupLCD()
displayString(1,0,"WELCOME")
displayString(2,0,"TO")
longDelay(4000)
displayString(1,0,"CIRCUIT")
displayString(2,0,"DIGEST")
longDelay(4000)
while(True):
displayString(1,0,"CIRCUIT")
displayString(2,0,"DIGEST")
longDelay(1000)
clearScreen()
longDelay(500)
And I get the error我得到了错误
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "lcd_pico.py", line 26, in setupLCD
NameError: name 'send2LCD4' isn't defined
Any ideas of what I can do?关于我能做什么的任何想法?
I tried to turn on a lcd using raspberry pi pico.我尝试使用 raspberry pi pico 打开液晶显示器。 I expected to see some text on the lcd, but, I get a error in the editor Thonny IDE我希望在 lcd 上看到一些文本,但是,我在编辑器中遇到错误 Thonny IDE
Obviously because you haven't defined you send2LCD4()
function.显然是因为你还没有定义你send2LCD4()
function。
I guess you used the example from here:我猜你使用了这里的例子:
https://www.instructables.com/Raspberry-Pi-PICO-LCD-not-I2C/https://www.instructables.com/Raspberry-Pi-PICO-LCD-not-I2C/
It's defined as:它被定义为:
def send2LCD4(BinNum):
d4.value((BinNum & 0b00000001) >>0)
d5.value((BinNum & 0b00000010) >>1)
d6.value((BinNum & 0b00000100) >>2)
d7.value((BinNum & 0b00001000) >>3)
pulseE()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.