Controlling a motor (5V Servo or 3V basic) with an NPN - Nano

Hi,

Arduino beginner here, blindly copying an internet recipe to make a toy for my child. I've managed to follow the circuit as posted online, and I now want to make one modification. Very grateful for some guidance on this

The circuit is to make a toy 'microwave' - the kid turns the rotary encoder and a 7 segment display displays a time. The kid then pushes the rotary encoder switch, and the display timer starts counting down. During countdown LEDs are lit. At the end of the countdown the LEDs turn off and a speaker makes a ping.

I want to add a motor in, so that while the LEDs are lit a motor is also spinning round (ie microwave plate spinning), then stops when the timer reaches zero.

I've got both a 5V servo and a 3V basic motor, happy to use either.

It was suggested by the original recipe creator that I could use D7 and basically copy the LED circuit but with the motor instead. However I'm stuck on what size resistor I'd need, and what the code would say

Any help very much appreciated

Finally I'm doing this all through USB at the moment but will want to use a battery pack when I go live. Any tips on what would fit this best? I have plenty of rechargeable batteries, AAA and AA. I am happy to use bigger batteries if needed, but ideally they'd last a long time as I don't have rechargeables, and don't want to buy new kit just for this. I was considering a solar power bank, maybe one which charges through mains too, so effectively a big battery, with a USB port so easy to switch to.

Circuit diagram and code attached

Micro_v1.ino (3.78 KB)

A typical servo output shaft rotates about 180 degrees. If you want to rotate a plate, use a continuous rotation servo.

Otherwise, you will need a gearmotor of some sort, as a "basic" 3V motor runs at thousands of RPMs.

For a gearmotor, you will need a suitable transistor switch or use a motor driver. Some ideas below:

Or a stepper motor.

my guess is one way is to hook up just the motor (at collector and vcc) and npn and its base goes to the arduino pins.
if turning on the npn turns on the motor, you could then try to pwm it to regulate the speed

Thanks for replies.

The motor circuit diagram is a lot more complex than I was hoping for so I'll try to get my head around it.

Are there any simple solutions? I like the look of a_g123's reply but hard to know how complex that is without a circuit diagram.

I don't understand the bit about 'pwm it to regulate the speed'

If you've got any time to expand a little that would be hugely appreciated, ideally with a diag.

here are the examples

https://forum.arduino.cc/index.php?topic=430990.msg2971060#msg2971060

https://www.youtube.com/results?search_query=pwm+motor+arduino

The simplest thing is a continuous rotation servo because it contains all of its own electronics and just needs its signal pin to be connected directly to an Arduino I/O pin. Use the Servo library to control it.

Give the servo its own power supply (usually 4.5 to 6v) with the servo GND connected to the Arduino GND.

...R

Amazing, thanks. I can cope with that level of complexity I think

Final question - what is my best bet to power this thing?

4 pack of AA batteries? A bigger one eg C or D battery size? Would a solar power bank be any good at all if I kept it topped up with mains charges?

Sorry for being so clueless!