i was following the Getting Started with MicroPython on Raspberry Pi Pico book and i am stuck at page 120, the example code did not work for some reason.
I am coding in VS Code, but just in case i tried running it in Thonny, still without any luck. I got the error(s):
- Argument of type "Literal['|']" cannot be assigned to parameter "buf" of type "bytes" in function "writeto" "Literal['|']" is incompatible with "bytes"
- Argument of type "Literal['hello world']" cannot be assigned to parameter "buf" of type "bytes" in function "writeto" "Literal['hello world']" is incompatible with "bytes"
- Argument of type "Literal['-']" cannot be assigned to parameter "buf" of type "bytes" in function "writeto" "Literal['-']" is incompatible with "bytes"
Then the lcd's backlight gets shut off and the top row became all black boxes.
The LCD and the i2c adapter works with C code but just in case i added the 4k7 resistors to the buses. (under micropython it didn't work no matter if i add them or not)
import machine
sda = machine.Pin(0)
scl = machine.Pin(1)
i2c = machine.I2C(0, sda=sda, scl=scl, freq=400000)
i2c.writeto(0x27, '\x7C')
i2c.writeto(0x27, '\x2D')
i2c.writeto(0x27, "hello world")
Also there isn't any pre-written library for this? Why is C easier than micropython for some stuff? (I am using this exact same setup using C/C++ with the Arduino library, but every piece of hardware is the same /pico, i2c adapter, 1602 green lcd/)