Hi everybody.Following my previous post, I'm trying to control with a potentiometer the rotation speed of a stepper motor. I was successfull following the sketch/code I found on Arduino, but now I want to go to the next step, controlling 2 steppers with each having their own potentiometer, and maybe adding a button to switch them off when I want to. is it possible?
I have a motorshield v1, which has 2 L293D chip, but I'm lost how to change the code , especially how to initialize the stepper library. here is the code I use and it works great, but how should I modify it in order to connect the 2 stepper motors and 2 potentiometers?
#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);
}
}
that will be kind of ridiculous to buy a second Arduino Uno and having 2 identical system side by side when I'm pretty sure there is a way to make it work with a single Uno+motorshield v1.
Thanks for your help!