hi dear friends i am trying to use map command which is used to power servo 180 degrees as the potentiometer move it forward (digitalWrite(I1, HIGH);
digitalWrite(I2, LOW)
and backward (digitalWrite(I1, HIGH);
digitalWrite(I2, LOW)![]()
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
myservo.write(val);
i am using normal dc motor and l293D IC but i want to control the dc as knob method like the 200 degrees please any help here i attached my urrent code
#define E1 11 // Enable Pin for motor
#define I1 10 // Control pin a for motor
#define I2 9 // Control pin b for motor
const int analogPin = A0;
int analogValue ;
void setup() {
pinMode(E1, OUTPUT);
pinMode(I1, OUTPUT);
pinMode(I2, OUTPUT);
}
void loop() {
int analogValue = analogRead(analogPin);
if(analogValue > 2 && analogValue < 500) {
analogWrite(E1, 255);
digitalWrite(I1, HIGH);
digitalWrite(I2, LOW);
delay(100);
} else
analogWrite(E1, 255);
digitalWrite(I1, LOW);
digitalWrite(I2, HIGH);
}
thanks in advance