Simple Machines + Python // Konrad Krawczyk

As I have had sizeable issues with successfully running the Kitten bot commands from the GUI-based code editor, I decided to post the successful version of the lab now that I got access to the robot via Python.

  1. Prior work & issues

The easiest part of this lab was really assembling the robot. It was extremely straightforward, picture-based, like building a Bionicle toy. The wiring was slightly different, but I adjusted accordingly.

Just like in the prior lab, I included the right pieces of code is that I could scroll a “Hello, World” on the display. The code worked with no issues.

The curve got steeper when I trued to include certain functionalities in the code editor. I tried to use the Robotbit library in the in-browser editor for a really long time, and every time it just did not happen. It took me a bit to figure that this was a bug in the browser, and I would have to use Safari.

Then when I got access to the right library, I tried inserting the code into Microbit. The graphical part (scroll) worked, but none of the motors got to work.

  1. Python

Once we together figured out how to use Python and put it in Robotbit, the motors finally started to work. With help from Tristan, I got to use the signal in the ultrasonic sensor to create conditions for the robot to change directions.

I got to: scroll a “hello world”, use the DC motors, and turn the servo around with Python code:

# Write your code here 🙂
from microbit import *
import robotbit

display.show(Image.HAPPY)

while True:

if (robotbit.sonar(pin1) > 30):
robotbit.motor(1, 100, 0)
robotbit.motor(4, -100, 0)
else:
robotbit.motorstop(1)
robotbit.motorstop(4)
robotbit.servo(7, 90)
robotbit.motor(0, 100, 500)

Leave a Reply