Hi. I'm building a peristaltic pump using a stepper motor controlled by a potentiometer+arduino
I followed the great instruction found on that webpage
but instead of using SN754410ne H-Bridge I took a L293D from a motor shield board L293D ( the one from amazon at $8.99)
It works great, but I'd like to get ride of the board and all the wires and because it's not convenient and messy I'd like to connect everything through the motorshield, and because I will be dealing with tubing, water and lot of others stuff I do not have wires all around. However, the code I'm using (see below), does not work when I connect the stepper motor through the motorshield. I guess it has to do with the digital entry 8,9,10,11, which are not accessible when you stack the motor shield on top of the Uno...What do I have to change into the code to make it work?
Also, I noticed even when the potentiometer is turn to zero, the motor is still under "tension" and you can hear a little noise, so it will be great to add a button switch off...where to put it on the and how to connect it to the motorshield? thank for your input!
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// nothing to do inside the setup
}
void loop() {
// read the sensor value:
int sensorReading = analogRead(A0);
// map it to a range from 0 to 100:
int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
// set the motor speed:
if (motorSpeed > 0) {
myStepper.setSpeed(motorSpeed);
// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);
}
}