Machine module error - cant import machine module on micropython

I want to control the leds as I want using the p9813 led driver and I am using Jetson Nano. There is a ready-made code that I found on github. I try this but I get module error. I’ve looked through machine modules from Pypi and I’m still getting the same error even though I’ve installed a few of them. Which machine module do I need to install?

from machine import Pin
import p9813

pin_clk = Pin(5, Pin.OUT)
pin_data = Pin(4, Pin.OUT)

num_leds = 10
chain = p9813.P9813(pin_clk, pin_data, num_leds)

#set the first LED to red
chain[0] = (255, 0, 0)

#set the second LED to green
chain[1] = (0, 255, 0)

#rite data to all LEDs

#make all LEDs red

#turn off all LEDs

I have micropython-p9813 (1.0.0), machine (0.0.1) and Python-Machine (1.0.2) but I get an error while installing machine-py. I got this error in other places as well, but I could not solve it. I am using pip3.

Command “python egg_info” failed with error code 1 in /tmp/pip-build-f1m5t3ju/matplotlib/

Or is there any other way i can control the led driver with jetson nano?

hello bugrahan.ismailoglu,

it looks like 1st line report an error, it’s machine module contains specific functions related to the hardware on a particular board.
these code looks toggle RGB LED pins, you may adapt those changes into GitHub - NVIDIA/jetson-gpio: A Python library that enables the use of Jetson's GPIOs

Thank you for answering. actually i tried to try that too, but i got an error at some point. Now I’ll try again and I can ask questions again.

I looked at the link you sent, but although I did it step by step, I couldn’t quite understand it. sample scripts do not work because it is a module used in rasberry pi. I guess I need to examine the complete library API part?

Additionally, do you have a solution for the machine module?

hello bugrahan.ismailoglu,

you should make sure that you’re trying to run your program on micropython board.
can you try modify the code to import machine to resolve this?

Dear Jerry,

I have examined this link in detail, but unfortunately I could not do exactly what I wanted to do. This defines the pins using gpio in the link you posted. But I also use the p9813 library. Here I need to import machine
and some functions in this library are used. So actually I still haven’t been able to do exactly what I wanted to do.

As I mentioned, I also specified the modules I loaded in the source attachment. Is there anything else I should do?

hello bugrahan.ismailoglu,

what’s the failure now?
please confirm you’re able to import all those necessary libraries.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.