Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8013

MicroPython • Re: MicroPython uname, machine modules not installed

$
0
0
When you do >>>help('machine') , as the response indicates, the help see's that you want help on a string ("machine") and proceeds to show all the info on whats available to the string class. You will get the same response if you do >>>help(str)

What you were probably looking for is to do a >>>dir(machine) where you will see
['__class__', '__name__', 'ADC', 'I2C', 'I2CTarget', 'I2S', 'PWM', 'PWRON_RESET', 'Pin', 'RTC', 'SPI', 'Signal', 'SoftI2C', 'SoftSPI', 'Timer', 'UART', 'USBDevice', 'WDT', 'WDT_RESET', '__dict__', 'bitstream', 'bootloader', 'deepsleep', 'dht_readinto', 'disable_irq', 'enable_irq', 'freq', 'idle', 'lightsleep', 'mem16', 'mem32', 'mem8', 'reset', 'reset_cause', 'soft_reset', 'time_pulse_us', 'unique_id']

and in that response is the Pin method.

And dont forget that when importing a module you dont include the .py bit. I put a full working bit of code for turning your LED on and off.

ps. when asking for help with code it mightily helps if you include a full code snippet. I cant advise on why your led_onboard = machine.Pin("LED", machine.Pin. OUT) did not work as you did not show the full code. It could be for a whole host of reasons, but probably you did not import the machine module correctly.

Code:

import machineimport timeled_onboard = machine.Pin("LED", machine.Pin. OUT)def flash_led(blink_duration):    while True:        led_onboard(1)        time.sleep(blink_duration)        led_onboard(0)        time.sleep(blink_duration)        # binks LED every secondflash_led(1)

Statistics: Posted by SirFico — Sun Jan 18, 2026 8:58 pm



Viewing all articles
Browse latest Browse all 8013

Trending Articles