[[PageOutline]] == XIAO RP2040 * 2022/11/01 Amazon ¥1,419.- ||[[Image(XiaoRP2040.png, 400)]]|| [KhoPyboard PyBoard一覧に戻る] == XIAO RP2040 の動作ログ * USBケーブルで接続し、!TeraTerm で開くと MicroPython が動作している {{{ >>> help() Welcome to MicroPython! For online help please visit https://micropython.org/help/. For access to the hardware use the 'machine' module. RP2 specific commands are in the 'rp2' module. Quick overview of some objects: machine.Pin(pin) -- get a pin, eg machine.Pin(0) machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p methods: init(..), value([v]), high(), low(), irq(handler) machine.ADC(pin) -- make an analog object from a pin methods: read_u16() machine.PWM(pin) -- make a PWM object from a pin methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d]) machine.I2C(id) -- create an I2C object (id=0,1) methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True) readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg) machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1) methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf) machine.Timer(freq, callback) -- create a software timer object eg: machine.Timer(freq=1, callback=lambda t:print(t)) Pins are numbered 0-29, and 26-29 have ADC capabilities Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN Useful control commands: CTRL-C -- interrupt a running program CTRL-D -- on a blank line, do a soft reset of the board CTRL-E -- on a blank line, enter paste mode For further help on a specific object, type help(obj) For a list of available modules, type help('modules') >>> >>> help('modules') __main__ gc uasyncio/event umachine _boot lwip uasyncio/funcs uos _boot_fat math uasyncio/lock urandom _onewire micropython uasyncio/stream ure _rp2 mip ubinascii urequests _thread neopixel ucollections uselect _uasyncio network ucryptolib usocket _webrepl ntptime uctypes ussl builtins onewire uerrno ustruct cmath rp2 uhashlib usys dht uarray uheapq utime ds18x20 uasyncio/__init__ uio uwebsocket framebuf uasyncio/core ujson uzlib Plus any modules on the filesystem >>> >>> help(rp2) object is of type module country -- PIOASMEmit -- __file__ -- rp2.py asm_pio -- const -- PIOASMError -- PIO -- __name__ -- rp2 asm_pio_encode -- StateMachine -- Flash -- dht_readinto -- _pio_funcs -- {'in_': None, 'y_dec': 4, 'pin': 6, 'iffull': 64, 'gpio': 0, 'not_osre': 7, 'clear': 64, 'rel': at 0x20008a50>, 'wrap': None, 'x_not_y': 5, 'word': None, 'out': None, 'push': None, 'noblock': 1, 'pull': None, 'wrap_target': None, 'x_dec': 2, 'mov': None, 'irq': None, 'set': None, 'y': 2, 'x': 1, 'null': 3, 'pc': 5, 'invert': at 0x20008a30>, 'pins': 0, 'not_x': 1, 'not_y': 3, 'ifempty': 64, 'isr': 6, 'pindirs': 4, 'exec': 8, 'label': None, 'status': 5, 'nop': None, 'osr': 7, 'block': 33, 'reverse': at 0x20008a40>, 'jmp': None, 'wait': None} >>> }}} [KhoPyboard PyBoard一覧に戻る]