I want to use Python code to control Maqueen.
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
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)
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
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
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
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
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
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
https://www.dfrobot.com/wiki/index.php/ ... U:_ROB0148
---> "What are the features of Maqueen?
Support for Makecode, will support Scratch and python later."
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
https://www.dfrobot.com/wiki/index.php/ ... U:_ROB0148
---> "What are the features of Maqueen?
Support for Makecode, will support Scratch and python later."
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
https://www.dfrobot.com/wiki/index.php/ ... U:_ROB0148
---> "What are the features of Maqueen?
Support for Makecode, will support Scratch and python later."
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
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
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
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
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)