2 DC Motors + L293d using analog pins to virtual pins

Could someone help to figure out convert the analog pin of potentiometer to a virtual pins so i can use the slider widget to control my motors

int enablePin = 11;
int in1Pin = 10;
int in2Pin = 12;
int switchPin = 7;
int potPin = 14;

int enablePin2 = 6;
int in3Pin = 9;
int in4Pin = 8;
int switchPin2 = 16;
int potPin2 = 15;

void setup() {
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(switchPin, INPUT_PULLUP);

pinMode(in3Pin, OUTPUT);
pinMode(in4Pin, OUTPUT);
pinMode(enablePin2, OUTPUT);
pinMode(switchPin2, INPUT_PULLUP);

}
void loop()

{

int speed = analogRead(potPin) / 4;
boolean reverse = digitalRead(switchPin);
setMotor(speed, reverse);

int speed2 = analogRead(potPin2) / 4;
boolean reverse2 = digitalRead(switchPin2);
setMotor2(speed2, reverse2);
}

void setMotor(int speed, boolean reverse)

{
analogWrite(enablePin, speed);
digitalWrite(in1Pin, ! reverse);
digitalWrite(in2Pin, reverse);
}

void setMotor2(int speed2, boolean reverse2)
{
analogWrite(enablePin2, speed2);
digitalWrite(in3Pin, ! reverse2);
digitalWrite(in4Pin, reverse2);

A virtual pin is essentially a Blynk specific variable.

Look at the virtual pin reference in the DOCs and keep searching around this forum for the massive amounts of example code that is available.[quote=“JSav, post:1, topic:11940”]
convert the analog pin of potentiometer to a virtual pins
[/quote]

It would be more functional to have a slider widget replace the potentiometer.

Slider set to V0 & range 0-255
Digital PWM pin 9

BLYNK_WRITE(V0)  // Slider widget - this function gets called every time slider is moved.
{
  int slideValue = param.asInt();  // Get the slider value.
  analogWrite(9, slideValue);  // Send value to digital pin
}

Thanks, ill take a look

sorry gunner but still don’t know how, here’s a schematic
https://circuits.io/circuits/4084416-motor-controller

Have you searched around this forum for others attempts to do something simular?

yeh, i found nothing

Really? :neutral_face:

I just found three since I last asked you. Try again with some relevant search parameter, I simply used motor control, but you could possibly add the number of a certain motor controller chip (PS, use the correct number :wink: )

yeah sorry, l293d

I fixed your title for you… now get searching… :slight_smile:

@JSav Find them yet?

Well, I am crashing for the night, so here is one link that should help you get started: