Kiddo Robot Extension
This extension provides a comprehensive set of blocks for controlling the Kiddo Robot, including sensors, actuators, and other utilities. It is designed to work with the MakeCode editor and supports various functionalities such as motor control, sensor reading, IR remote control, and RGB LED control.
Created by Edusharks
π Features
- Motor Control: Manage motors individually or simultaneously.
- Sensor Integration: Line follower and ultrasonic distance sensors.
- IR Remote Control: Receive and handle IR signals.
- RGB LED Support: Control NeoPixel LED strips with color options.
- Servo Motors: Control positional and continuous rotation servos.
π οΈ Installation
- open https://makecode.microbit.org/
- click on New Project
- click on ** βExtensions** under the Block menu
- π search for https://github.com/edusharks/kiddo_blocks and import
π Usage
Pins
- Digital Read: Get a digital value (0/1) from a pin.
Kiddo.digitalRead(Kiddo.kiddoDigitalPin.P3)
- Digital Write: Set a digital value (0/1) to a pin.
Kiddo.digitalWrite(Kiddo.kiddoDigitalPin.P3, 1)
- Analog Read: Get an analog value (0-1023) from a pin.
Kiddo.analogRead(Kiddo.kiddoAnalogPin.P3)
- Analog Write: Set an analog value (0-1023) to a pin.
Kiddo.analogWrite(AnalogPin.P3, 512)
π Sensors
Line Follower
- Initialize Line Follower:
Kiddo.initializeLineFollower()
- Read Right Sensor:
Kiddo.readRightLineFollowerSensor()
- Read Left Sensor:
Kiddo.readLeftLineFollowerSensor()
Ultrasonic Sensor
- Initialize Ultrasonic Sensor:
Kiddo.initializeUltrasonicSensor()
- Detect Obstacle Distance:
Kiddo.detectObstacleDistance(Kiddo.Unit.Centimeters)
π§ Actuators
Motors
- Control Motor:
Kiddo.controlMotor(Kiddo.Motor.R, Kiddo.Direction.Forward, 50)
- Stop Motor:
Kiddo.stopMotor(Kiddo.Motor.R)
- Move Both Motors:
Kiddo.move(Kiddo.Direction.Forward, 50)
RGB LED
- Initialize LED Strip:
Kiddo.initializeLedStrip()
- Set LED Color:
Kiddo.setLedColor(0xFF0000)
- Clear LED:
Kiddo.clearLed()
Servo Motors
- Move Positional Servo:
Kiddo.movePositionalServo(DigitalPin.P0, 90)
- Move Continuous Servo:
Kiddo.moveContinuousServo(DigitalPin.P0, 50)
- Stop Continuous Servo:
Kiddo.stopContinuousServo(DigitalPin.P0)
π Examples
Line Following Robot
Kiddo.initializeLineFollower()
basic.forever(function () {
if (Kiddo.readLeftLineFollowerSensor() === 1 && Kiddo.readRightLineFollowerSensor() === 1) {
Kiddo.move(Kiddo.Direction.Forward, 50)
} else if (Kiddo.readLeftLineFollowerSensor() === 1) {
Kiddo.controlMotor(Kiddo.Motor.R, Kiddo.Direction.Forward, 50)
Kiddo.stopMotor(Kiddo.Motor.L)
} else if (Kiddo.readRightLineFollowerSensor() === 1) {
Kiddo.controlMotor(Kiddo.Motor.L, Kiddo.Direction.Forward, 50)
Kiddo.stopMotor(Kiddo.Motor.R)
} else {
Kiddo.stopAllMotors()
}
})
IR Remote Controlled Robot
Kiddo.initializeIrReceiver()
Kiddo.onIrButton(Kiddo.IrButton.CH, Kiddo.IrButtonAction.Pressed, function () {
Kiddo.move(Kiddo.Direction.Forward, 50)
})
Kiddo.onIrButton(Kiddo.IrButton.CH, Kiddo.IrButtonAction.Released, function () {
Kiddo.stopAllMotors()
})
π License
This project is licensed under the MIT License. See the LICENSE
file for details.
π Contributing
Contributions are welcome! If you have improvements or new features to add, feel free to submit a pull request or open an issue.
Happy coding with Kiddo Robot! ππ€
Got any adjustments in mind or new features you want to highlight? Let us know! β¨