micropython – My raspberry pi pico gives me a strange error
So I want to turn on a lcd 16×2 using my Raspberry Pi Pico but it can’t detect the file requested. 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
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 Iget 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. I expected to see some text on the lcd, but, I get a error in the editor Thonny IDE
Read more here: Source link