Howto run a 12V bipolar stepper motor with arduino micro and L298N at 150rpm

Today I experimented with a 12V bipolar stepper motor and the 5V arduino micro.

To get things working I’ve put the 9V from my six 1.5V Batteries into an UBEC which accelerates them to 12V at a loss of below 10% (at 350mAh) connected them to the VCC of the L298N and wired the 4 signal cables of the motors to it. Because thats a lot of numbers to keep track of – I’ve made a small video of the setup:

Doing the math according to a wheel with 5,8cm heigth and 150rpm I’ve reached, my robot will be able to run about 1,6 km/h – this might be increased with a better motor driver like they used on the arduino motor shield. I’ve read they reached about 250 rpm on the same motor which would be 2,73km/h.

The code of the arduino is pretty simple:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

#include <Stepper.h>

constintstepsPerRevolution=200;// change this to fit the number of steps per revolution