Meron:
This week, I worked on designing the new Phase 2 version of our auto-balance motorcycle. While the data team focused on programming the steering system, I continued improving the mechanical design. The new version is smaller and lighter than the one from Phase 1, and I also made the wheels thinner and added support wheels to help with balance.
The idea behind this design is to make it more realistic and ready for steering control in the next steps. The support wheels will help the motorcycle stay stable while testing. The goal is to make the design ready for both mechanical assembly and software testing so we can see movement and steering working together soon.

Salim:
As I mentioned last week, I will be focusing mainly on my engineering internship since it’s an important week there. However, I’ve now succeeded in getting the controller to work. There was a challenge with the R button (P16), as it is quite loose. Another issue I ran into was that without using pins.sets_pull, the left and backwards buttons would freeze on the buttons. It took some time to fix that. The main structure of the code is divided into three modes:
- Mode 0: Buttons – Left (P13), Backwards (P14), Forward (A), and Right (B).,
- Mode 1: Joystick – Activated by pressing L (P15), showing “J” for joystick. The X and Y axes of P1 and P2 control the directions.,
- Mode 2: Tilt – Activated by pressing R (P16), showing arrows that function the same way as the other modes.,
- Pressing R and L simultaneously returns the controller to Mode 0.,
- The buttons, joystick and tilt need to hold for it to move. because the standard is that the motorcycle dose not move. it will be shown whit stop “S” and “-“,
radio.on()
radio.set_group(67)
mode = 0
lastState = "STOP"
basic.show_string("S")
pins.set_pull(DigitalPin.P13, PinPullMode.PULL_UP)
pins.set_pull(DigitalPin.P14, PinPullMode.PULL_UP)
pins.set_pull(DigitalPin.P15, PinPullMode.PULL_UP)
pins.set_pull(DigitalPin.P16, PinPullMode.PULL_UP)
def vis_mode(symbol: str):
basic.show_string(symbol)
basic.pause(200)
basic.clear_screen()
def buttons():
global lastState
pressed = False
if input.button_is_pressed(Button.A):
radio.send_string("F")
basic.show_string("F")
pressed = True
lastState = "FORWARD"
elif input.button_is_pressed(Button.B):
radio.send_string("R")
basic.show_string("R")
pressed = True
lastState = "RIGHT"
elif pins.digital_read_pin(DigitalPin.P13) == 0:
radio.send_string("L")
basic.show_string("L")
pressed = True
lastState = "LEFT"
elif pins.digital_read_pin(DigitalPin.P14) == 0:
radio.send_string("B")
basic.show_string("B")
pressed = True
lastState = "BACKWARDS"
if not pressed and lastState != "STOP":
radio.send_string("S")
basic.show_string("S")
lastState = "STOP"
basic.pause(200)
def joystick():
global lastState
X = pins.analog_read_pin(AnalogPin.P1)
Y = pins.analog_read_pin(AnalogPin.P2)
pressed = False
if Y < 300:
radio.send_string("B")
basic.show_string("B")
pressed = True
lastState = "BACKWARDS"
elif Y > 700:
radio.send_string("F")
basic.show_string("F")
pressed = True
lastState = "FORWARD"
elif X < 300:
radio.send_string("L")
basic.show_string("L")
pressed = True
lastState = "LEFT"
elif X > 700:
radio.send_string("R")
basic.show_string("R")
pressed = True
lastState = "RIGHT"
if not pressed and lastState != "STOP":
radio.send_string("S")
basic.show_string("S")
lastState = "STOP"
def tilt():
xx = input.acceleration(Dimension.X)
yy = input.acceleration(Dimension.Y)
if yy < -300:
radio.send_string("F")
basic.show_leds("""
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
""")
elif yy > 300:
radio.send_string("B")
basic.show_leds("""
. . # . .
. . # . .
# # # # #
. # # # .
. . # . .
""")
elif xx < -300:
radio.send_string("L")
basic.show_leds("""
. . # . .
. # # . .
# # # # #
. # # . .
. . # . .
""")
elif xx > 300:
radio.send_string("R")
basic.show_leds("""
. . # . .
. . # # .
# # # # #
. . # # .
. . # . .
""")
else:
radio.send_string("S")
basic.show_leds("""
. . . . .
. . . . .
# # # # #
. . . . .
. . . . .
""")
basic.pause(100)
def on_forever():
global mode
L1 = pins.digital_read_pin(DigitalPin.P15) == 0
R1 = pins.digital_read_pin(DigitalPin.P16) == 0
if L1 and R1:
mode = 0
vis_mode("S")
basic.pause(200)
elif L1 and not R1 and mode != 1:
mode = 1
vis_mode("J")
basic.pause(200)
elif R1 and not L1 and mode != 2:
mode = 2
vis_mode("T")
basic.show_string("-")
basic.pause(200)
if mode == 0:
buttons()
elif mode == 1:
joystick()
elif mode == 2:
tilt()
basic.pause(100)
basic.forever(on_forever)
Muhammed Ø:
This week, I worked on implementing the servo control for the steering system for the motorcycle. The goal was to allow the front wheel to turn right and left based on the commands received from the remote controller.
The servo is connected to pin P0, and to the micro bit. The micro bit is receiving digital signals from the remote controller, therefore we dont have a way to continously adjust the servo position, I used a short delay in the code after one second the servo automatically returns to its neutral position (90 degrees). This temporary solution allows the wheel to return to center after each turn. When the system receives an “L” command, the servo turns to 150 degrees (left turn) and when it receives an “R” command, it turns to 30 degrees (right turn).
In the future, we plan to move away from digital control signals and instead use analog signals (PWM). This will allow us to control the servo angle more precisely and create smoother, more realistic steering behavior.
this is the updated code:
def servo_left():
servos.P0.set_angle(150)
basic.pause(1000)
servos.P0.set_angle(90)
def motor_forward():
pins.digital_write_pin(DigitalPin.P8, 1)
# ENA HIGH
pins.digital_write_pin(DigitalPin.P3, 1)
pins.digital_write_pin(DigitalPin.P1, 0)
def motor_backward():
pins.digital_write_pin(DigitalPin.P8, 1)
# ENA HIGH
pins.digital_write_pin(DigitalPin.P3, 0)
pins.digital_write_pin(DigitalPin.P1, 1)
def motor_stop():
pins.digital_write_pin(DigitalPin.P8, 0)
# ENA LOW
pins.digital_write_pin(DigitalPin.P3, 0)
pins.digital_write_pin(DigitalPin.P1, 0)
def servo_right():
servos.P0.set_angle(30)
basic.pause(1000)
servos.P0.set_angle(90)
message = ""
# Sett opp radio
radio.set_group(67)
servos.P0.set_angle(90)
def on_forever():
global message
message = radio.receive_string()
if message == "F":
basic.show_string("F")
motor_forward()
elif message == "B":
basic.show_string("B")
motor_backward()
elif message == "L":
basic.show_string("L")
servo_left()
elif message == "R":
basic.show_string("R")
servo_right()
else:
motor_stop()
basic.show_string("S")
basic.forever(on_forever)