If all is well, this will print the result 4. If you are running on Windows, you will need to type t = Talker('COM6') replacing COM6 by whatever port the Pico is visible on. In that directory, run python3 to start an interactive session.py from this github gist into an editor and save it in a directory of your choice. Raise ValueError( 'expected %s got %s' % (text, reply)) If reply != text: # the line should be echoed, so the result should match Reply = reply.replace( '> ', '') # lines after first will be prefixed by a propmt rial = serial.Serial( '/dev/ttyACM0', 115200, timeout=timeout) It uses PySerial to send commands from the host to the Raspberry Pi Pico and read the result. Since you saved the program as main.py it will run on the Pico automatically. If you leave the Thonny editor open it will keep the serial port open on the host, and the serial program below will not work! Paste the code into the Thonny editor window.Open Thonny and make sure it has connected to the Pico.Led.value(0)Install it on the Pico using the Thonny editor. # led = Pin('LED', Pin.OUT) # version for Pico W Led = Pin(25, Pin.OUT) # veresion for Pico # on a Pico W the onboad lLED is accessed differently, # use onboard LED which is controlled by Pin 25 It sets up the onboard LED and allows you to turn it on or off. Here's the code: """Įxample for remote control from host via Serial link. The blinker.py script runs on the Pico, but you should rename it to main.py. Connect the host and the Picoįirst, connect the host to the Pico using a USB data lead. The guide will also tell you how to use the Thonny editor to install the necessary code on your Pico. The £10 Guide is worth buying, but if you can't wait for your copy to arrive you can download a free pdf. You'll find instructions for MicroPython installation in the official Getting Started Guide which I reviewed recently. You'll need to install MicroPython on the Pico. The host needs to have the serial package available, so you need to run In particular, you can use this technique to connect a Raspberry Pi Pico to a Jetson Nano host or any other member of the Jetson family. Setting up the host and the Picoįor this article I've used a Raspberry Pi as the host, but any computer running Windows, Linux or Mac OS will do so long as it has Python 3.5 or later installed. The statement can be any valid MicroPython code. It enables you to send a Python statement to the Pico and read the results.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |