Code for stopping a 12vDc brushed motor with

I’ve attached some screen shots of a project Im starting. Its a poster display. 12v battery supply (10.5Ah and 126Whr), A housing, rollers and belts - just to give you an idea of what Im doing. Im going to turn a roller 10 times with the motor (specs attached). The roller and motor have a 1:1 ratio. When the roller turns 10 times it will stop for 15 minutes. It stops by using a micro-switch (one that suits) which will sense one of two tabs at either end of the main belt then go again for the next poster. it’ll do this for the 6 posters, then do the same in reverse. Im just curious, can I code it to carry out these tasks or no?? Is the motor able to switch tot the opposite direction, I know using a H-bridge would allow this but how would I integrate it? I’d love a link to some kind of generic code to help me out here. Total newbie and I know I should have researched it in the ‘tutorials’ and the ‘playground’ and that but its 1:00am here so just thought I’d ask the wonderful folk on here to give me a dig out. Maybe someone could do me a HUGE favour and help me out with some code. You can assume whatever you like but be nice an dont be giving out to the newbie :wink: Thanks people and I hope to wake up to a wealth of new code and knowledge :slight_smile: Cheers

Overview of housing with panels + door suppressed.JPG

Top roller.JPG


Yeah, you'll need an H-Bridge to flip the motor direction. It's pretty easy actually and this shield can drive up to 2 amps per motor so you might want to give this one a shot.

If you want it to spin a number of times and stop you should measure how long it takes to spin that number of times and put a delay for that long.

Oh thanks, thats great. Measure how long it takes in seconds or rpm?? Could you give me an example of the code required? And can I simply tell the motor to flip using the arduino (and the H-bridge) by coding or?? Again, could you give me a link for some examples. I've never coded. Just an example so i can get the hang of it. Thanks for your help.

The H-Bridge has no idea how times the motor has turned. You cannot trust time alone to indicate a complete move. You need to sense a limit switch perhaps the existing microswitch is suitable.

Yeah measure in seconds. But it's not a very precise way to get the right number of turns, so you might need to use a rotary encoder but I don't have any experience with them. However the H-bridge shield is pretty easy and there's even example code on the site I sent you earlier.