#28625
Hello,
I checked the Maqueen movement with the makecode linked below.
But I'd like to test the same behavior with Python.
Coding the motors with Python is not easy.
I think the motor is supposed to work with I2C, but can you tell me how to code it in Python to do the same thing as the link below?
https://makecode.microbit.org/v0/06010- ... 4565-76380

Especially, I don't know how to specify addr and buff as the argument value of the write function. #i2c.write(addr, buf, repeat=False)

[*]Running the code below will cause the following error:
File "__main__", line 10, in <module>
OSError: I2C write error -1010
Code: Select all
#MicroPython + Grove I2C motor driver 
from microbit import *

#i2c.init(freq=100000, sda=pin20, scl=pin19)

while True:
    # Forwards
    print('Forwards')
    display.show(Image.ARROW_N)
    i2c.write(0x0f, bytearray([0x82,0x46,0x46]))
    i2c.write(0x0f, bytearray([0xaa,0x0a,0x01]))
    sleep(3000)
    # Stop
    i2c.write(0x0f, bytearray([0x82,0x00,0x00]))
    i2c.write(0x0f, bytearray([0xaa,0x0a,0x01]))
    sleep(2000)
    # Backwards
    display.show(Image.ARROW_S)
    print('Backwards')
    i2c.write(0x0f, bytearray([0x82,0x46,0x46]))
    i2c.write(0x0f, bytearray([0xaa,0x05,0x01]))
    sleep(3000)
    # Stop
    i2c.write(0x0f, bytearray([0x82,0x00,0x00]))
    i2c.write(0x0f, bytearray([0xaa,0x0a,0x01]))
    sleep(2000)
    # Slow Turn Left
    display.show(Image.ARROW_W)
    print('Left Turn')
    i2c.write(0x0f, bytearray([0x82,0x46,0x46]))
    i2c.write(0x0f, bytearray([0xaa,0x09,0x01]))
    sleep(3000)
    # Stop
    i2c.write(0x0f, bytearray([0x82,0x00,0x00]))
    i2c.write(0x0f, bytearray([0xaa,0x0a,0x01]))
    sleep(2000)
    # Sharp Right Turn
    display.show(Image.ARROW_E)
    print('Right Turn')
    i2c.write(0x0f, bytearray([0x82,0x46,0x46]))
    i2c.write(0x0f, bytearray([0xaa,0x06,0x01]))
    sleep(3000)
    # Stop
    i2c.write(0x0f, bytearray([0x82,0x00,0x00]))
    i2c.write(0x0f, bytearray([0xaa,0x0a,0x01]))
    sleep(5000)
#28636
Thanks for the good information, but what I want to know is the python code that get Maqueen to move. I don't know the interface (method) that can make the motor move because the motor is connected by I2C. Is there any Python example code for Maqueen? Please, help me..

In other words, I've checked that the maqueen is working with the macecode linked below, and I want to do the same with python.
https://makecode.microbit.org/v0/06010- ... 4565-76380
#28824
Now I'm using McQueen on Mind+ and other editors by python. It is supposed to use the urm10 module to operate ultrasound, but I would like to use another editor other than Mind+. Is the "urm10" python module supported by Mind+? Where can I get an "urm10" module?
#41375
Hi

Can you please tell me how you got this working on Python. Can you please share your code? did you need to download any modules. If you did what were they?

I would really appreciate any help. I try to run it on Mind+ but it throws and unable to write to 12c error.

Thanks