13 febrero 2021 Por Sharath 0

Getting Started with Pico on Windows with Thonny Python

The Raspberry Pi Pico is the latest flexible microcontroller from Raspberry Pi. In this tutorial, we will see how to use the Pico on Windows Operating System with the Thonny Python IDE.

Components Required:

Step 1: Download and install Python

Visit the python website and download the latest version of python for Windows.

Then Thonny IDE

Step 2: Press the BOOTSEL pin on your Pico and Connect the Raspberry Pi Pico and you can able to see the Pico Mounted as a Flash Drive. Open the Index.html file and it will head over to raspberry pi pico page. Here we need to download the UF2 File to your computer (for now).

Step 3: Drag and Drop or Copy the UF2 File that we downloaded on your computer to the Pico. Now the pico will eject itself. Now the micropython is running in our Raspberry Pi Pico. We can able to see that pico device on our Thonny IDE.

Step 4: Open Thonny IDE, and at the right bottom of the window click the button and you can able to see ‘MicroPython (Raspberry Pi Pico)’ select it. Now we are ready to code.

Step 5: We can use shell or the python file to code our raspberry pi. Using shell you can test line by line code. Using python file, you can write complete code, then run it using the Pico.

Printing ‘Hi Pico Factory’ on Shell

Let’s try to run this on our Pico. Write ‘Hello from Pico” on the code area and click the Play Icon in the IDE. Now the result will be printed on the output.

Step 6: Testing with On-board LED.

In Pico we have on-board LED as well as Temperature Sensor. So first we will see how to turn ON and OFF LED with basics.

from machine import Pin
ledpin = Pin(25, Pin.OUT)
ledpin.value(1)
print("LED is ON")

OUTPUT:

After run this code by pressing the play button the On-board LED will be ON. The Python code runs only once. So that, we can see the ‘LED is ON’ is printed only once and not printing continuously like in Arduino c language. To achieve the loop, we can use while loop to run our code continuously, when we use sensor readings.

Similarly, the ledpin.value(0) turns OFF the LED.

LED Blinking with utimer:

In this example, we will blink the led using utimer library. The ‘while True:’ syntax runs the code in a loop. For debugging purpose, we printed the LED Status on output.

from machine import Pin
import utime

ledpin = Pin(25, Pin.OUT)

while True:
    ledpin.value(1)
    print("LED ON")
    utime.sleep(1)
    ledpin.value(0)
    print("LED OFF")
    utime.sleep(1)

The post Getting Started with Pico on Windows with Thonny Python first appeared on FactoryForward. The Raspberry Pi Pico is the latest flexible microcontroller from Raspberry Pi. In this tutorial, we will see how to use the Pico on Windows Operating System with the Thonny Python IDE. Components Required: Raspberry Pi Pico microUSB Cable Thonny IDE Python Step 1: Download and install Python Visit the python website and download the
The post Getting Started with Pico on Windows with Thonny Python first appeared on FactoryForward. (FUENTE ORIGINAL a un solo click en) —-> Read More (publicado gracias a) —-> FactoryForward