" Arduino Speed/Direction control with 4 DC Motors and 2 Pots, need help "
Hi everyone,
I need some knowledge of yours. I am newbie and I have encountered with some problems. I hope that some of you might answer my questions below, thanks.
I am using this Arduino sketch as a backbone while using diot, transistor,pot,and resistor for dc speed control.
And this is the code that I am using to control the speed of dc motor :
int analogInPin = A0;
int sensorValue1 = 0;
int outputValue = 0;
int transistorPin1 = 3;
void setup() {
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(transistorPin1, OUTPUT);
}
void loop() {
sensorValue1 = analogRead(analogInPin)/4;
outputValue = map(sensorValue1, 0, 1023, 0, 255);
analogWrite(transistorPin1, sensorValue1);
if (sensorValue >= 160) { //example
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
} else {
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
}
delay(10);
}
This sketch and controlling speed of 1 dc motor works fine. However, it doesn't work with multiple dc motors. I tried some addings to see if I can do the way I want ;but as always failed :(.
I added these to see what will happen ( if it works or not; and it doesn't work ) :
int sensorValue2 = 0;
int transistorPin2 = 17;
analogWrite(transistorPin1 , sensorValue1);
analogWrite(transistorPin2 , sensorValue1);
I want to learn that is there something like while writing in analogWrite, digitalRead at etc. commands ?
analogWrite(transistorPin1 && transistorPin2, sensorValue1);
How can I control speed of 4 dc motors with potentiometer while using diot and transistor ;and how might be the new sketch ( I need to make another diot and transistor connections to my breadboard for 2nd-3rd-4th dc motors ) ? I don't have any problem at 1 dc motor speed control with 1 potetiometer coding or sketch; but I cannot move 4 dc motors with above coding ,even I tried to add/do something myself but failed.
For dc motor's direction controls ( forward/backward,brake,reverse ) I need to have a motor shield or we can do it without motor shields too ? if it is possible without motor shield would you give me a guidance website link please ;or if we need a motor shield which shield is easy to use ( which ons has more tutorial with some sample,basic examples : Arduino motor shield or Adafruit motor shield or dfrobot motor shield or any brand motor shields ) ?