moto:bit for microbit with c++ runtime?

Hello! I have used this tutorial https://www.edgeimpulse.com/blog/voice- … d-microbit for the Micro:bit to create a voice recognition program for my microbit. I now want to make it so that the microbit controls a servo anytime someone says my keyword.

I have a Moto:bit board, and was wondering how/if I can use the c++ runtime ( https://lancaster-university.github.io/ … docs/ubit/ )to control a servo connected to the Moto:bit?

Code atm is this, which is of course showing a smiley face :smiley: whenever the keyword is said. I want to replace this with the servo going one way for the keyword, and the other way for when it doesnt hear the keyword.

/**

  • Invoked when we hear the keyword !

*/

static void heard_keyword() {

const char * happy_emoji ="\

000,255,000,255,000\n\

000,000,000,000,000\n\

255,000,000,000,255\n\

000,255,255,255,000\n\

000,000,000,000,000\n";

MicroBitImage img(happy_emoji);

uBit.display.print(img);

}

/**

  • Invoked when we hear something else

*/

static void heard_other() {

const char * empty_emoji ="\

000,000,000,000,000\n\

000,000,000,000,000\n\

000,000,255,000,000\n\

000,000,000,000,000\n\

000,000,000,000,000\n";

MicroBitImage img(empty_emoji);

uBit.display.print(img);

Seems simple enough to change, but if someone could point me in the right direction that would be very helpful to me.

Using the Moto:bit would be great bc then I can use stronger servos without having to fiddle with power supplies etc.

Thanks!/J

You likely just need to add the servo library and invoke a servo value/position instead of the img; here’s a guide on the MakeCode Servo library/functions https://support.microbit.org/support/so … -micro-bit

Thank you! How can I invoke the library if I cannot use the makecode, to program the microbit?

The voice recognition program is here on github, and you cant import the hex file into makecode after you compile it unfortunately. So I have to program it “by hand” to say…

Can I just write analog pwm signal to a pin which the moto:bit servo is connected to and make it work that way?

heres the project from edge impulse btw: https://github.com/edgeimpulse/voice-activated-microbit

Very nifty being able to do voice recognition on a micro:bit :slight_smile:

Thanks!

/J

I noticed that the servo pins on the moto:bit is p15 and p15 on the microbit. These pins are digital only on the microbit, i think…? I was under the impression that you cant control servos using pwm on digital pins, yet obviously im wrong.

My question is I guess… Can I use the moto:bit board without makecode or libraries to use with the project i linked to above, or do I have to use the analog capable pins and make my own power supply for the servo?

I hope that makes sense!

/J