{"id":31702553,"url":"https://github.com/thomasduvinage/dfrobot-maqueenplus-python","last_synced_at":"2025-10-08T21:52:56.649Z","repository":{"id":72122851,"uuid":"359937737","full_name":"ThomasDuvinage/DFRobot-Maqueenplus-Python","owner":"ThomasDuvinage","description":"Python implementation of the DFRobot Maqueenplus library.","archived":false,"fork":false,"pushed_at":"2024-10-28T01:24:58.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-28T05:24:15.187Z","etag":null,"topics":["dfrobot","microbit","robot","teaching-tool"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThomasDuvinage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-20T20:05:23.000Z","updated_at":"2024-10-26T16:42:33.000Z","dependencies_parsed_at":"2024-10-28T02:45:34.266Z","dependency_job_id":"61d585f0-096c-4175-a227-af62b86d5193","html_url":"https://github.com/ThomasDuvinage/DFRobot-Maqueenplus-Python","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ThomasDuvinage/DFRobot-Maqueenplus-Python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDuvinage%2FDFRobot-Maqueenplus-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDuvinage%2FDFRobot-Maqueenplus-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDuvinage%2FDFRobot-Maqueenplus-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDuvinage%2FDFRobot-Maqueenplus-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasDuvinage","download_url":"https://codeload.github.com/ThomasDuvinage/DFRobot-Maqueenplus-Python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasDuvinage%2FDFRobot-Maqueenplus-Python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000693,"owners_count":26082837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dfrobot","microbit","robot","teaching-tool"],"created_at":"2025-10-08T21:52:51.333Z","updated_at":"2025-10-08T21:52:56.644Z","avatar_url":"https://github.com/ThomasDuvinage.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DFRobot-Maqueenplus-Python\n\nPython library for the Maqueen Plus robot developed by DFRobot. \n\nThis library is a python version of the one proposed by DFRobot used for block coding. \n\nThis version has been developed for students to let them play and enjoy coding this nice little robot.\n\nLink to DFRobot page : [https://www.dfrobot.com/product-2026.html]\n\n# Usage \n\n- Create robot object\n\nInstantiate the robot object \n\n```python\nimport microbit\nimport lib_robot_maqueen as mqn\nimport time #can be removed if not used\n\nmq = mqn.MaqueenPlus()\n```\n\n# Methods \n\n### Move the robot\nMove the robot along 4 axis :\n- F -\u003e forward\n- B -\u003e backward \n- L -\u003e left\n- R -\u003e right \n\nFunction definition :\n```python\ndef move(speed, dir):\n    \"\"\"\n    speed(pwm) : 0 -\u003e 255\n    dir(string) : \"F\" or \"B\" or \"L\" or \"R\"\n    \"\"\"\n```\n\nExample :\n```python \n    mq.move(70, \"F\")\n    time.sleep(1) #wait for 1s\n    mq.move(70, \"R\")\n```\n\nTo move the robot you can also use the motorControl method.\n\nFunction definition :\n```python\ndef motorControl(self, mot, dir, spd):\n    \"\"\"\n        mot left: MT_L ; mot right: MT_R\n        dir (forward): 1; dir (backward): 2\n        spd max: 255; stop: 0\n    \"\"\"\n```\n\nExample :\n```python \n    mq.motorControl(mq.MT_L,2,50)\n    mq.motorControl(mq.MT_R,2,70)\n```\n\n### Move the robot for a precise distance\nMaqueenPlus is equipped with wheel encoders. The function goto uses the wheel encoders to turn or move the robot over an exact number of encoder ticks:\n- F -\u003e drive a number of encoder ticks forward\n- L -\u003e turn left for a number of encoder ticks\n- R -\u003e turn right for a number of encoder ticks\n\nFunction definition :\n```python\ndef goto(self, dir, spd, dist):\n    \"\"\"\n        mot left: MT_L ; mot right: MT_R\n        dir(string) : \"F\" or \"L\" or \"R\"\n        spd max: 255; stop: 0\n        dist: the number of encoder ticks the robot should move\n    \"\"\"\n```\n\nExample :\n```python\n    # drive forward with PWM speed 200 for 400 encoder ticks\n    mq.goto(\"F\", 200, 400)\n\n    # turn left with PWM speed 70 for 144 ticks (about 180 degrees)\n    mq.goto(\"L\", 70, 144)\n```\n\n### Stop \nStop the robot \n\nFunction definition:\n```python\n    def stop(self):\n        \"\"\"Stop the robot \n        \"\"\"\n```\n\nExample:\n```python\n    mq.stop()\n```\n\n### Control ServoMotor\nYou can move three servos with the version of the library, S1, S2, S3.\n\nFunction definition:\n```python\n    def servo(self, number, angle):\n        \"\"\"Move a servo for a given angle\n\n        Args:\n            number (int): number of the servo to move\n            angle (int): rotating angle (min=0  max=180)\n        \"\"\"\n```\n\nExample:\n```python\n    mq.servo(mq.S3,90)\n    time.sleep(1)\n    mq.servo(mq.S3,0)\n```\n\n### Line tracking sensor\nRead line tracking sensor state.\nNot all the functions proposed by DFRobot have been implemented.\nIt is up to you to do so.\n\nFunction definition:\n```python\n    def getLine(self):\n        \"\"\"Read line tracking state\n\n        Returns:\n            dictionary of [int]: 0 : white / 1 : black\n            valid keys for the dictionary are: \"L3\", \"L2\", \"L1\", \"R1\", \"R2\", \"R3\"\n        \"\"\"\n```\n\nExample:\n\n```python\n    #Read line tracking sensor state\n    line = mq.getLine()\n    print(line[\"L1\"])\n    print(line[\"R1\"])\n```\n\n### Ultrasonic sensor \nGet the distance between the robot and an object. An optional argument maxDist was added so you can choose the range of the sensor, which can be important to limit delays in your program. The default setting is 0.4 meters.\n\nFunction definition:\n```python\n    def ultrasonic(self,maxDist=0.4):\n        \"\"\"Get the distance between the robot and an object.\n\n        Args:\n            [float, optional] The maximum distance in meters\n                              If function is called with no arguments, defaults to 0.4\n\n        Returns:\n            [float]: distance to the object if one is detected, else max value.\n        \"\"\"\n```\n\nExample:\n\n```python\n    distance = mq.ultrasonic()\n    distance = mq.ultrasonic(0.8)\n```\n\n### Motor Speed \nGet the linear speed of a given motor. \nINFO : This method has no been tested yet but you can test it and set an issue for feedback. \n\n\nFunction definition:\n```python\n    def motorSpeed(self, mot):\n        \"\"\"Get the linear speed of a given motor \n\n        Args:\n            mot (int): object attribute define in the constructor (MG, MD)\n\n        Returns:\n            [type]: [description]\n        \"\"\"\n```\n\nExample:\n\n```python\n    mq.move(70, \"F\")\n    time.sleep(1) #delay is necessary. Otherwise the robot read the speed before the motor started.\n    spd = mq.motorSpeed(mq.MT_L)\n    display.show(str(spd))\n    time.sleep(5)\n    mq.stop()\n```\n\n### RGB Lights\nTurn on/off the rgb light of your choice with the color you want.\n\n* RGB LED choice:\nRGB_L : left led,\nRGB_R : right led,\nRGB_ALL : both leds\n\n* Color choice:\nRED,\nGREEN,\nBLUE,\nYELLOW,\nPINK,\nCYAN,\nWHITE,\nOFF\n\nFunction declaration:\n```python\n    def RGBLight(self, rgbshow, color):\n        \"\"\"Turn on/off the rbg light of your choice with the color you want.\n\n\n        Args:\n            rgbshow (int): rgb light object attribute defined in the constructor :\n                RGB_L : left led,\n                RGB_R : right led,\n                RGB_ALL : both leds\n\n            color (int): color of the led:\n                RED,GREEN,\n                BLUE,YELLOW,\n                PINK,CYAN,\n                WHITE, OFF\n        \"\"\"\n```\n\nExample:\n```python\n    mq.RGBLight(mq.RGB_L,mq.RED)\n```\n\n### Read Encoders\nRead the values of the wheel encoders\n\nFunction definition:\n```python\n    def getEncoders(self):\n        \"\"\"Read the values of the wheel encoders\n        \n        Returns:\n            [tuple of 2 int's]: Value of the left encoder and right encoder\n        \"\"\"\n```\n\nExample:\n```python\n    encoders = mq.getEncoders()\n    print(encoders[0])\n    print(encoders[1])\n```\n\n### Clear Encoders \nReset the values of the wheel encoders to 0\n\nFunction definition:\n```python\n    def clearEncoders(self):\n        \"\"\"Reset the values of the wheel encoders to 0\n        \"\"\"\n```\n\nExample:\n```python\n    mq.clearEncoders()\n```\n\n### Version history\n- Version 1.0: Initial version\n- Version 2.0: Compacted code style (short variable names, delete unnecessary space characters) to work around memory constraints and find space for adding functionality. Added goto function for moving the robot with use of the decoders. Added optional maximum distance argument to the ultrasonic function. Should still work with the micro:bit V1. if more functions to this library are added, you will probably need to equip your Maqueen Plus with the micro:bit V2. I am considering making a separate version of this library for the micro:bit V2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasduvinage%2Fdfrobot-maqueenplus-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasduvinage%2Fdfrobot-maqueenplus-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasduvinage%2Fdfrobot-maqueenplus-python/lists"}