0

I'm trying to set up a raspberry pi pico for the first time. I've got micropython installed, and got my environment set up in Pycharm. I wrote a simple program to test my setup, and I'm getting this error:

Traceback (most recent call last):
File "D:\...\Blink.py", line 1, in <module>
    from machine import Pin
ModuleNotFoundError: No module named 'machine'

Here's the code:

from machine import Pin
import time

led = Pin(25, Pin.OUT)
while True:
    led(1)
    time.sleep(1)
    led(0)
    time.sleep(1)

I've found other questions where people had a similar problem when using an ESP32, but I'm wondering how to handle this in pycharm with a pi pico

tylerst
  • 45
  • 6
  • The `machine` module is only available when running micropython code *on the Pico*. I'm not familiar with Pycharm, but are you certain it isn't just trying to run your code with regular Python on your development machine? – larsks Feb 21 '22 at 00:07
  • I'm not entirely certain. I'm following a tutorial on YouTube, and the process worked for him. – tylerst Feb 21 '22 at 00:48

2 Answers2

0

are you sure running the code in the pico not in your computer. Use Thonny IDE because you can easily run and save the code in pico link to download thonny ide and then use this link to know how to set up this ide to run code in pico

rami atallah
  • 104
  • 5
0

When I make a new project and try to run using the green arrow at the top right of Pycharm, I get this message. But if I right-click my source code in the project tree and choose "Run Flash ...", it starts working.