Ibrahim Aslan
Ibrahim Aslan

Reputation: 1

main.py not running when I start Raspberry Pi Pico

My code:

print("hello world")

I want this file to run when I start the Raspberry Pi Pico. I named it main.py but when I unplugged and plugged the Raspberry Pi Pico into my computer the program didn't start.

Upvotes: 0

Views: 885

Answers (1)

brainelectronics
brainelectronics

Reputation: 95

in order to get the output of the device on your machine (Windows, Linux or Mac) you have to open the port to see that output, e.g. with PuTTY, rshell, mpremote... Whenever you unplug and replug the device that port might be different depending on the machines operating system.

Other than that it could be also the case that your device is printing the message before you even connected to that port and your program finished already when you open the port.

You could change you code of the main.py file to the following to print "Hello World, iteration #x" in an endless loop with a one second delay between two messages.

import time
iteration = 0
while True:
    iteration += 1
    print("Hello World, iteration #{}".format(iteration))
    time.sleep(1.0)

Upvotes: 1

Related Questions