By larry
#42153
I checked your link and downloaded the folder. It contains the Mu Python editor. I did not see anything else there.
By larry
#42155
I'm using Mind+ to code the Maqueen using Python. I get a I2C write error -1010.
Can you please help. We would like to purchase several of these robots for schools. I like the robot performance using MakeCode. However, we need to be able to use Python. Mind+ seems to be good software, but I have not been able to upload code and run the robot with success.
#42156
Code for a maqueen.py module to save in microbit memory with Mu
Code: Select all
from microbit import *
import time
from neopixel import NeoPixel
import machine
class Maqueen():
    def __init__(self,addr=0x10):
        self.addr=addr
        self._vg=0
        self.s=0
        self.np=NeoPixel(pin15,4)
    def getSpeed(self):
        return self._vg
    def setSpeed(self, v):
        self._vg=v
    def calc_vs(self,v):
        if v==None:
            v=self.vg
        self.s=0 if v>=0 else 1
        return(int(abs(v)*255/100))
    def stop(self):
        i2c.write(self.addr,bytearray([0,0,0,0,0]))
        time.sleep(1.5)
    def motor_right(self,v=None):
        v=self.calc_vs(v)
        i2c.write(self.addr,bytearray([2,self.s,v]))
    def motor_left(self,v=None):
        v=self.calc_vs(v)
        i2c.write(self.addr,bytearray([0,self.s,v]))
    def forward(self,v=None):
        v=self.calc_vs(v)
        i2c.write(self.addr,bytearray([0,0,v,0,v]))
    def back(self,v=None):
        v=self.calc_vs(v)
        i2c.write(self.addr,bytearray([0,1,v,1,v]))
    def rotate_r(self,v=None):
        v=self.calc_vs(v)
        i2c.write(self.addr,bytearray([0,0,v,1,v]))
    def rotate_l(self,v=None):
        v=self.calc_vs(v)
        i2c.write(self.addr,bytearray([0,1,v,0,v]))
    def distance(self):
        pin1.write_digital(1)
        time.sleep_ms(10)
        pin1.write_digital(0)
        pin2.read_digital()
        t2 = machine.time_pulse_us(pin2,1)
        d = 340 * t2 / 20000
        return d
    def led_left(self, e=0):
        pin8.write_digital(e)
    def led_right(self, e=0):
        pin12.write_digital(e)
    def line_left(self):
        return(pin13.read_digital())
    def line_right(self):
        return(pin14.read_digital())
    def lum_on(self,RGB=[0,255,0]):
        for i in range(4):
            self.np[i] = (RGB)
        self.np.show()
    def lum_off(self):
        self.np.clear())
example of code to flash as main.py with Mu
Code: Select all
from maqueen import *
import random
robot=Maqueen()
time.sleep(2)
sens=0
while True:
    robot.forward(20)
    d=robot.distance()
    while d>8:
        d=robot.distance()
    sens=random.randint(0,1)
    if sens==0:
        robot.rotate_r(70)
        robot.led_right(1)
    else:
        robot.rotate_l(70)
        robot.led_left(1)
    delai=0.7
    time.sleep(delai)
    robot.led_right(0)
    robot.led_left(0)
edit: code translation to english
By nana.wang
#42170
larry wrote:
Tue May 26, 2020 8:12 pm
I'm using Mind+ to code the Maqueen using Python. I get an I2C write error -1010.
Can you please help. We would like to purchase several of these robots for schools. I like the robot performance using MakeCode. However, we need to be able to use Python. Mind+ seems to be good software, but I have not been able to upload code and run the robot with success.
Hi Larry,
thank you for your support and contact.
Could you please check the details as follows and feedback:
1. Could you please take a picture of the hardware connection? It is probably caused by a loose connection. So please check it first, especially the power connector.
2. Please try to upload and run the python library in offline mode of mind+ for more than once and check the result.
3. Please try the python library in make-code to test it.
4. Please check the power supply interface to check whether it is loosed, or change the other power supply.
5. Please try it with the other micro: bit in mind+.
#42174
Hi nana.wang,

I'm using microbit:maqueen bot with students in highschool in France. It's a great device to learn programming basics!
With these students, aged between 15 and 17, we are supposed to use litteral code (python) instead of graphic blocs.

As I've posted it before, I've found some information to build a first maqueen module. This module include most of the bot features but I have some questions to ask you.

As Larry asked, why is the repositery you've pointed before empty ? (except the Mu installer.)

Can you share the documentation of motor drive I2c protocol? (is there a way to program a running time for a move?)

Can you share code to use IR as distance sensor?

Thanks for your help!
#42221
Hi, in fact, the Mu installer in GitHub contains the full library of python in Maqueen.
You really can test it. In fact, we can also run Maqueen in Mind+, but you need to confirm the power supply in the central of the Mauqeen.
Once the power supply loosed, it will cause the I2c protocol failure.
Please note it.
By the way, we are preparing the tutorial of Mauqeen to run python. Thank you for all your consideration and support.