MotorCell isn't just for continuous motion - it can also be pulsed for a short bursts of movement. This is particularly useful for kinetic art projects, where controlled, rhythmic motion can create stunning visual effects. By pulsing the motor for a few milliseconds at a time, you can achieve coordinated spinning effects across multiple motors.
This example demonstrates how to pulse six motors for 2000 milliseconds (2 seconds) each, creating a sequential spinning effect. The function Pulse(IN_pinX, pulse_ms)
activates each motor for a set duration before moving to the next.
#include <MotorCell.h>
#define IN_pin1 1
#define IN_pin2 2
#define IN_pin3 3
#define IN_pin5 5
#define IN_pin6 6
#define IN_pin7 7
#define pulse_ms 2000
int motor_num = 0;
MotorCell myMotorCell(1,2,3);
void setup() {
}
void loop() {
delay(100);
motor_num++;
switch (motor_num) {
case 1:
myMotorCell.Pulse(IN_pin1, pulse_ms); /* Pulse motor 1 for 2000ms */
break;
case 2:
myMotorCell.Pulse(IN_pin2, pulse_ms); /* Pulse motor 2 for 2000ms */
break;
case 3:
myMotorCell.Pulse(IN_pin3, pulse_ms); /* Pulse motor 3 for 2000ms */
break;
case 5:
myMotorCell.Pulse(IN_pin5, pulse_ms); /* Pulse motor 5 for 2000ms */
break;
case 6:
myMotorCell.Pulse(IN_pin6, pulse_ms); /* Pulse motor 6 for 2000ms */
break;
case 7:
myMotorCell.Pulse(IN_pin7, pulse_ms); /* Pulse motor 7 for 2000ms */
motor_num = 0; /* Reset the sequence */
break;
}
}
motor_num
variable tracks which motor is currently active.motor_num
and selects the corresponding motor.Pulse(IN_pinX, pulse_ms)
is used to activate each motor for 2 seconds before moving to the next.pulse_ms
to adjust the spin time of each motor.Ready to start experimenting? Grab a MotorCell today and check out the MotorCell GitHub Repository for more code examples and technical documentation!
Join our Community ~ Be the first to know about new products and get exciting deals!
© 2025 Microbots.