Go back to product documents navigation
Go back to Robotbit Documents Navigation
Motor
Run the motor
robotbit.motor(motor number, speed, runtime)
- motor number: 0 (all motors), 1~4 (corresponds to M1A, M1B, M2A, M2B respectively)
- speed: -255~255, the negative number means to reverse the motor
- runtime: stop the motor after a period of time (ms); if set 0, then the motor won't stop.
import robotbit robotbit.motor(0, 255, 0) |
Stop the motor
robotbit.motorstop(motor number)
- motor number: stop the corresponding motor immediately; 0 (all motors), 1~4 (corresponds to M1A, M1B, M2A, M2B respectively)
import robotbit robotbit.motorstop(0) |
Servo
robotbit.servo(servo number, servo angle)
- servo number: 0~7 correspond to S1~S8 respectively
- servo angle: 0~180 correspond to the regular 9g servo (180°)
- If you're using Kittenbot geekservo (-45°~225°) and 2KG servo (0°~360°), then refer to the code below
import robotbit robotbit.servo(0, 90) # geekservo robotbit.servo(0, int((servo angle-90)/1.5+90)) # 2KG robotbit.servo(0, int((servo angle-180)*50/9+1500)) |
Stepper Motor
robotbit.stepper(stepper motor M1 angle, stepper motor M2 angle)
- the program would not run to the next step if the stepper motor does not turn to the set degree
- 360 means that the stepper motor turns 360°. The stepper motor here is 28byj.
import robotbit robotbit.stepper(0, 360) |
RGB LED
import microbit |
Buzzer
We use the official mocro:bit library here. The default is P0.
music.pitch(frequency, duration)
frequency-pitch reference
import music |
music.play(note)
- note = NOTE[octave][:duration]
import music |
Built-in melodies:
DADADADUM、ENTERTAINER、PRELUDE、ODE、NYAN、RINGTONE、FUNK、BLUES、BIRTHDAY、WEDDING、FUNERAL、PUNCHLINE、PYTHON、BADDY、CHASE、BA_DING、WAWAWAWAA、JUMP_UP、JUMP_DOWN、POWER_UP、POWER_DOWN
Run the official sample program and enjoy the melody:
from microbit import * |
Kittenbot Ultrasonic Sensor
It is an ultrasonic sensor with 2 RGB LEDs. For regular HC-04 ultrasonic sensor, please short-circuit the TRIG and ECHO
robotbit.sonar(pin)
import microbit |
If you have any question, please feel free to contact us at Discord, we will always be there to help.
KittenBot Team