RoboticsGeneral

I want to use Python code to control Maqueen.

userHead jkmcucu94 2019-02-24 19:08:31 38569 Views29 Replies

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)

2020-04-15 21:16:13 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
userHeadPic vidura04
2020-04-15 21:16:13 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
userHeadPic vidura04
2020-04-15 21:16:13 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
userHeadPic vidura04
2019-07-02 17:34:32 Is there any chance the image showing some sample code in python could be posted again? I run a MacBook and thus can't download make+ at this point so looking at other means of coding the Maqueen with Python. userHeadPic grant.haggerty
2019-07-02 17:34:32 Is there any chance the image showing some sample code in python could be posted again? I run a MacBook and thus can't download make+ at this point so looking at other means of coding the Maqueen with Python. userHeadPic grant.haggerty
2019-07-02 17:34:32 Is there any chance the image showing some sample code in python could be posted again? I run a MacBook and thus can't download make+ at this point so looking at other means of coding the Maqueen with Python. userHeadPic grant.haggerty
2019-03-21 21:18:35 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? userHeadPic jkmcucu94
2019-03-21 21:18:35 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? userHeadPic jkmcucu94
2019-03-21 21:18:35 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? userHeadPic jkmcucu94
2019-02-26 19:24:23 Thank you very much, the attached image helped me a lot. Maqueen moved successfully with Python. ^^ userHeadPic jkmcucu94
2019-02-26 19:24:23 Thank you very much, the attached image helped me a lot. Maqueen moved successfully with Python. ^^ userHeadPic jkmcucu94
2019-02-26 19:24:23 Thank you very much, the attached image helped me a lot. Maqueen moved successfully with Python. ^^ userHeadPic jkmcucu94
2019-02-26 16:11:27 Hi, Mind+ supports Micropython and Maqueen now. userHeadPic robert.chen
2019-02-26 16:11:27 Hi, Mind+ supports Micropython and Maqueen now. userHeadPic robert.chen
2019-02-26 16:11:27 Hi, Mind+ supports Micropython and Maqueen now. userHeadPic robert.chen
2019-02-26 14:18:39 The link below says that Python will be supported later. Is it true that it is not supported yet?

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 jkmcucu94
2019-02-26 14:18:39 The link below says that Python will be supported later. Is it true that it is not supported yet?

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 jkmcucu94
2019-02-26 14:18:39 The link below says that Python will be supported later. Is it true that it is not supported yet?

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 jkmcucu94
2019-02-25 18:09:04 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
userHeadPic jkmcucu94
2019-02-25 18:09:04 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
userHeadPic jkmcucu94