Approved content
The content below is provided by a partner.
You can control KeiganMotor KM-1 Series from micro:bit via RADIO
日本語はこちら→(Japanese) https://github.com/keigan-motor/pxt-KeiganMotor/blob/master/README_ja.md
Product page: https://keigan-motor.com
micro:bit cannot talk to KeiganMotor via RADIO when the firmware of micro:bit is compiled by the latest makecode editor. So please ise the above old editor “version v1” as follows.
You need to change KeiganMotor’s RADIO mode from BLE to “micro:bit mode”.
Once set to micro:bit mode, KeiganMotor will start with micro:bit mode after shutdown. If you push Stop Button 10 times again, it will be back to BLE mode.
Make a new project and add KeiganMotor extension to the project.
You need to specify KeiganMotor’s unique 4 digits “name” and its RADIO group for micro:bit to control wirelessly. It is used in initializer of KeiganMotor on MakeCode editor as belows.
It is a unique specific 4 digit number of KeiganMotor. You can know it by two ways as belows.
You need to match RADIO group between MakeCode and KeiganMotor. The default RADIO group of KeiganMotor is 0. RADIO group can be from 0 to 255. If you want to control multiple KeiganMotors, you should assign separate RADIO group to them. (Please refer to the section “Control Multiple KeiganMotors” as belows.)
Use the following project.
https://makecode.microbit.org/_fbvR7ifav6Ht
Use the following project.
https://makecode.microbit.org/_2RoaiV5R4Y3T
Make KeiganMotor rotate and control LED.
https://makecode.microbit.org/_6ARcAWbt5cDq
// Initialize KeiganMotor by RADIO group and its name
// RADIO group should be from 0 to 255
let m = keiganmotor.create(0, "EFGH") // RADIO group ID = 0, name = "EFGH"
m.enable()
m.runRpm(10) // run at velocity 10 [rotation/minute]
basic.pause(10000) // wait for 10 seconds
m.stop() // stop (set speed to 0)
m.led(led_state.ON_SOLID, 255, 255, 0) // Set LED color to RGB(255,255,0) = yellow
You should change RADIO groupId separately to avoid to get jammed.
let m1 = keiganmotor.create(0, "EFGH")
let m2 = keiganmotor.create(1, "PQRS")
m1.enable()
m2.enable()
If you want to control multiple KeiganMotors that have the same RADIO group ID, You can avoid to get jammed by inserting “basic.pause(50)” between commands as belows.
m1.moveToDeg(30)
basic.pause(50)
m2.moveToDeg(-30)
MIT
KeiganMotor=github:keigan-motor/pxt-KeiganMotor#v1.0.5