Here’s a new Raspberry Pi Pico guide “How to use Raspberry Pi Pico with Thonny”
After weeks of searching this is the only webpage that tells me how to set up Micropython for Win10 - the crucial SET UP THONNY section.
By this I mean that at last I can BLINK the Pico onboard LED.
On Win10, strictly following the book brought up error: ModuleNotFoundError: No module named ‘machine’.
This webpage was clear and simple AND WORKS!
Thanks from UK!
Hey David,
Welcome to the forum!
That’s brilliant, glad to hear that Michaels’ tutorial was helpful to you, I’ll let him know! Have a great day! And please let us know if you have any questions about the Pico.
Hi,
It’s also handy to know that if you are using the wifi version, pin 25 is not directly connected to the LED.
So the line
led = Pin(25, Pin.OUT)
Should be changed to
led = Pin(“LED”, Pin.OUT)
For the code to work properly.
Am I doing something wrong here?
I have a replacement computer and trying to look at my Pico which has a Python program to see if my backup is the latest. Any ideas?
Thanks,
Brian Steinke
Thanks. I am playing to buy a pico. This one may help me a great deal.
Welcome back Brian
At a glance it seems your doing everything right, I have a feeling it might be wifi related but if you cant install micropython through Thonny you can manually install it by:
- Downloading a UF2 image: MicroPython - Python for microcontrollers
- As you did before hold down the bootsel button and load up Windows explorer
- Pop the UF2 you downloaded into the folder and observe it closes
- Open Thonny and connect to the Pico again - fingers crossed everything should be working!
Thonny version 4.0.0 has the links for the Pico W in the “Install and update Micropython” area.
But I have found it to be a “hit and miss”, sometimes it works other times not. It also takes some time for the links to appear, sometimes.
Manual drag and drop of the .uf2 file is what I tend to do now, it works and is much faster.
The names have been changed on the Pico W Micropython web page, they no longer have “unstable” in the name and the Pico W is on Nightly Builds, no release version. It is possible the name change has caused the links in Thonny no longer work.
Links to download pages.
Micropython Pico
Micropython Pico W
Regards
Jim
EDIT: @Brian22570 it also looks like you are running an older version of Thonny. This is what I get on Thonny 4.0.0. Although it lists with “unstable” in the name and not the lastest build.
This what I get for a Pico. Thonny seems to work better than it did a few days ago.
Thanks Liam. All fixed.
Keep up the good work, you are a real asset to us would be makers.
Cheers,
Brian
Thanks James. All fixed.
Keep up the good work for us would be makers.
Cheers,
Brian
PS I can now work on submitting my parking sensor as a project for your site.
Hi ,thank you for your very helpful tutorial.
Your code to make the on board led flash worked but the code from the supplier Ercrow didn’t.
It throws up a syntax error at the while statement?
Can you explain what is wrong with their code or is it my set up?
Cheers Steve
Hi @Stephen232509, welcome to the forums.
It would be helpful if you included the code in question, along with the error messages from Thonny
Wrap your code in ‘backticks’ to format it correctly. you can copy and paste the following block to get started:
```
your code here
```
Hi Michael, thanks for taking the time to help me with this.
This code posted by Elecrow, the company I purchased the micro Pi kit from does not work.
I am not sure if I have set set up the uF2 file correctly either.
Their code is:
from machine import Pin
import utime
led=Pin(25,Pin.OUT)
if_name_==“main”:
while True:
led.value(1)
utime.sleep_ms(100)
led.value(0)
utime.sleep_ms(100)
Hope you manage to get this!
Cheers Steve
PS: I can’t find the back ticks on my phone. Sorry.
Hope you don’t mind me butting in.
The problem is with the inverted commas around “Main” as far as I can tell.
They have been translated to the wrong value. Quotes rather than inverted commas.
Regards
Jim
Errored Code:
from machine import Pin
import utime
led=Pin(25,Pin.OUT)
if_name_==“*main* ”:
while True:
led.value(1)
utime.sleep_ms(100)
led.value(0)
utime.sleep_ms(100)
Correct code:
from machine import Pin
import utime
led=Pin(25,Pin.OUT)
if _name_ == "main":
while True:
led.value(1)
utime.sleep_ms(100)
led.value(0)
utime.sleep_ms(100)
EDIT: That is the syntax error, but really if _name_ == "main":
is not needed if this it the complete code.
Hi Jim,
thank you very much.
You were right and yes, it does work fine without the if statement.
I have never really used a forum like this before; it’s great! I am a noob so still finding my way round!
Looking forward to making progress now.
Thank you very much.
Steve