Im creating a car with the microbit. I have all the components running, and the car built. the rear wheels run of DC circuit motors. How would I code in microbit, to make the power supply or the motor only last 5 seconds.
Thank you.
Im creating a car with the microbit. I have all the components running, and the car built. the rear wheels run of DC circuit motors. How would I code in microbit, to make the power supply or the motor only last 5 seconds.
Thank you.
You might be better off starting with some of the example projects on the microbit site, because as it stands your question is quite vague. Here is a JavaScript example, assuming you need to drive pin0 to control the motor.
function onStart( ) {
// Turn the motor on
microbit.writePinDigital(0, true);
// Wait 5 seconds
wait(5000);
// Turn the motor off
microbit.writePinDigital(0, false);
}
For this to be really useful, you'll need some sort of control algorithm in order to decide when to turn on and off the motors. Have you got a motor driver board? Otherwise, your micro:bit probably won't have enough power to turn the motors (and it might be damaged too). These are details that you should really add to your question - they make it easier for people to write good answers.