My project consists of a motor which should move forward for a few seconds, then reverse for a few seconds, at the input of an external button.
Below are pictures of my code, and my wiring.
It is not working at all, the motor does not move, I’m not sure if it’s supposed to do this or not but when I press the button, the button turns of the microbit, then pressing it again turns it on.
Pls any help would be very appreciated, I’m quite new to microbits and I’m struggling to get my project to work.
Sorry I don’t have the motor in the picture but you get the idea
Have you tried a higher speed? Many DC motors will not operate at low speeds.
If you are trying to insert “stranded” wires in the sockets on the board, you may want to use a different approach, like something with a solid pin. Twisted wires often don’t make firm connections when they are pushed into the sockets.
If you have access to a voltmeter or know someone who does, you may want to: a) change the program so Button A turns the Motor on (full speed) and Button B turns it off, b) then use the meter in place of the motor to measure if there is voltage being applied and also use the meter on the motor wires in place of the micro:bit (and measuring resistance) to confirm a complete circuit.
Quick follow-up: I noticed that you’re using on pin P2 pressed. If you haven’t already done so, you may want to try on Button A pressed first — that may help identify if the problem is due to detecting the button press or in controlling the motor. (And maybe do a separate piece of code that uses on pin P2 pressed to show a specific picture on the screen).
Thanks for the help, you have a good point about the stranded wires, I’m going to try and get something to divide the wires into a solid point.
I’m definitely going to experiment with the micro bit, try and figure out the problem step by step.
Kind regards
Alligator clips with Dupont ends can be handy for testing stuff like this.
You can find them on Amazon, Alibaba, etc. For example: https://www.amazon.com/Dupont-Breadboard-Jumper-Alligator-Arduino/dp/B086MVXPVY. I tear them into individual clips — pin in the board and clamp the alligator to the motor wire(s) for testing, etc.
Good luck and please share any progress or problems!