ELECFREAKS
Published

Micro:bit Steering Car

Hi everyone, today I will teach you how to make a steering car with our micro:bit Wonder Building Kit, the principle is very simple, mainly

BeginnerFull instructions provided2 hours465
Micro:bit Steering Car

Things used in this project

Hardware components

BBC micro:bit V2
×2
micro:bit Wonder Building Kit
×2
Joystick:bit 2 Kit
×1

Software apps and online services

KidsIoT
Hardware Source

Story

Read more

Schematics

Hardware Connection

Connect the motor and servo to the M2 and S1 ports on the Wukong expansion board respectively.

micro:bit-Steering-Car.pdf

Build-up steps in PDF:

Code

car program:

JavaScript
radio.onReceivedValue(function (name, value) {
    if (name == "angle") {
        wuKong.setServoAngle(wuKong.ServoTypeList._360, wuKong.ServoList.S1, value)
    } else if (name == "speed") {
        wuKong.setMotorSpeed(wuKong.MotorList.M2, value)
    }
})
radio.setGroup(1)
wuKong.setServoAngle(wuKong.ServoTypeList._360, wuKong.ServoList.S1, 180)
basic.showIcon(IconNames.Heart)

Joystick:bit program:

JavaScript
let speed = 0
let angle = 0
radio.setGroup(1)
basic.showIcon(IconNames.SmallHeart)
joystickbit.initJoystickBit()
basic.forever(function () {
    angle = pins.map(
    joystickbit.getRockerValue(joystickbit.rockerType.X),
    0,
    1023,
    80,
    280
    )
    if (joystickbit.getButton(joystickbit.JoystickBitPin.P13)) {
        speed = 100
    } else if (joystickbit.getButton(joystickbit.JoystickBitPin.P14)) {
        speed = -100
    } else {
        speed = 0
    }
    radio.sendValue("angle", angle)
    radio.sendValue("speed", speed)
})

Credits

ELECFREAKS
11 projects • 0 followers
ELECFREAKS focuses on the micro:bit developed kits and accessories. We are one of the official partners of the BBC micro:bit Foundation.
Contact

Comments

Please log in or sign up to comment.