'How to use user input in pi Pico Device mini controller [closed]
I have tried to get user input in pico thonny but i can't get user input
from machine import Pin
a = input()
print(a)
Solution 1:[1]
To use Thonny with the Pico, you first need to configure Thonny to interact with the Pico via the serial port:
- Go to the "Run" menu, and choose "Select interpreter..."
- Under "Which interpreter or device should Thonny use for running your code?", choose "MicroPython (Raspberry Pi Pico)" (if that is in fact what you're using).
- Under "Port", select the appropriate serial port. If you're unsure what port to use, you can try leaving it set to "Try to detect port automatically".
After completing the above steps, in the "Shell" panel at the bottom of your window you should see something like:
MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>>
At this point, if you enter your code in the code panel and click the "Play" button (or select "Run -> Run current script"), you should first be prompted where to save the script. You can save it either locally on your computer or on the Pico.
Once the script has been saved, in the "Shell" window you should now see:
>>> %Run -c $EDITOR_CONTENT
At this point, the script is running and is waiting for user input. Place the cursor at the bottom of the panel, and then type something and press <RETURN>. You should see your text echoed back to you:
>>> %Run -c $EDITOR_CONTENT
this is a test
this is a test
>>>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | larsks |
