Driving a stepper motor with Ledlabs Electronic Workbench
Various methods of stepper motor control can be achieved for the type used here
The 28-BYJ48 Stepper Motor that comes supplied with the Lab is a 4 phase unipolar type
Geared stepper motor
Voltage: 5V
Step Angle: 5.625 x 1/64
Reduction ratio: 1/64
5-wire 4-phase Can be driven by ordinary uln2003 chip.
Below is an Arduino program which allows the stepper motor to move proportionally to the rotation value of a potentiometer connected to Analog input A0
This example code is in the public domain.
Copy and paste the code into the Arduino programming environment, or load it from the example program already within the Arduino software. A couple of changes in the code may be required to suit the stepper motor itself, change the step angle from #define STEPS 100, to 64 in order to suit the stepper motor supplied.
The speed can also be changed in the code.
A tie wrap is useful to fix around the motor shaft so as to see it moving as these are small increments, some motors have different step resolutions like 1.8 degrees/step or 3.6 etc.
Connect digital pins 8,9,10,11 from the ATMega section in sequential order to the ABCD inputs of the stepper motor controller on Ledlabs to suit the below program.
Connect the potentiometer wiper to Analog input A0 as indicated on the ATMega section.
Connect the stepper motor to the 5 pin header on ledlabs with the red wire to the right hand side. The order depending on colour code of the motor at the connector end is usually
Purple, pink,yellow,orange, red.
The potentiometer above the breadboard can be used, or wiring one up on the breadboard.
If using potentiometer on Ledlabs just the wiper output connects to A0, if wiring one up on the breadboard, connect the other two terminals to +5v and 0v, on Ledlabs and the wiper to A0.
The library function file Stepper.h requires installing in the arduino ide software, select tools, manage libraries, then in the search box 'type' stepper, then click and install.
Another way to drive without using code, could be like this:
Connect the Pwm output from the bass module into the spare 4017 clock input, this acts as a clock input.
Connect the first four outputs of this counter to the input of the ABCD inputs to the stepper module, play some music/sound and the motor should move to sound. the output of the bass filter may require connecting to the hex buffers, the spare connectors of the schmitt trigger before connecting to the stepper
The code for driving stepper motor is below
/*
* MotorKnob
*
* A stepper motor follows the turns of a potentiometer
* (or other sensor) on analog input 0.
*
* http://www.arduino.cc/en/Reference/Stepper
* This example code is in the public domain.
*/
#include <Stepper.h>
// change this to the number of steps on your motor
#define STEPS 100
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);
// the previous reading from the analog input
int previous = 0;
void setup() {
// set the speed of the motor to 30 RPMs
stepper.setSpeed(30);
}
void loop() {
// get the sensor value
int val = analogRead(0);
// move a number of steps equal to the change in the
// sensor reading
stepper.step(val - previous);
// remember the previous value of the sensor
previous = val;
}