Introduction
Previously, we showed you how to get the Bird Bot moving in First Steps with Bird Bot.Â
In this guide, learn to create a controller for the Bird Bot, with another micro:bit! You will learn to use the built-in accelerometer and bluetooth antennae found on the micro:bit. We will program it in Microsoft MakeCode. Note: You will need a second micro:bit for this guide!
Complete this guide to create your own Bluetooth-controlled Bird Bot in no time.
In this guide, learn to create a controller for the Bird Bot, with another micro:bit! You will learn to use the built-in accelerometer and bluetooth antennae found on the micro:bit. We will program it in Microsoft MakeCode. Note: You will need a second micro:bit for this guide!
Complete this guide to create your own Bluetooth-controlled Bird Bot in no time.
Tools
-
-
-
-
-
-
-
-
-
-
function forward () { basic.showArrow(ArrowNames.North); pins.digitalWritePin(DigitalPin.P8, 1); pins.servoWritePin(AnalogPin.P8, 180); pins.digitalWritePin(DigitalPin.P16, 1); pins.servoWritePin(AnalogPin.P16, 0); basic.clearScreen(); } function backward () { basic.showArrow(ArrowNames.South); pins.digitalWritePin(DigitalPin.P8, 1); pins.servoWritePin(AnalogPin.P8, 0); pins.digitalWritePin(DigitalPin.P16, 1); pins.servoWritePin(AnalogPin.P16, 180); basic.clearScreen(); } function turnLeft () { basic.showArrow(ArrowNames.West); pins.digitalWritePin(DigitalPin.P8, 1); pins.servoWritePin(AnalogPin.P8, 180); basic.pause(100); basic.clearScreen(); } function turnRight () { basic.showArrow(ArrowNames.East); pins.digitalWritePin(DigitalPin.P16, 1); pins.servoWritePin(AnalogPin.P16, 0); basic.pause(100); basic.clearScreen(); } function stop () { pins.digitalWritePin(DigitalPin.P16, 0); pins.digitalWritePin(DigitalPin.P8, 0); } radio.onReceivedNumber(function (receivedNumber) { basic.pause(200); if (receivedNumber == 0) { forward(); basic.pause(2000); stop(); } if (receivedNumber == 1) { backward(); basic.pause(2000); stop(); } if (receivedNumber == 2) { turnRight(); basic.pause(2000); stop(); } if (receivedNumber == 3) { turnLeft(); basic.pause(2000); stop(); } if (receivedNumber == 4) { stop(); } }) radio.setGroup(1) basic.forever(function () { basic.pause(200); if (input.buttonIsPressed(Button.A)) { radio.sendNumber(0); } if (input.buttonIsPressed(Button.B)) { radio.sendNumber(1); } if (input.acceleration(Dimension.X) > 1022) { radio.sendNumber(2); } if (input.acceleration(Dimension.X) < -1022) { radio.sendNumber(3); } })
-
-