Quiero remplazar dos interruptores físicos por dos virtuales (V7 y V8)

#define BLYNK_PRINT Serial
 
#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>


// You should get Auth Token in the Blynk App.

// Go to the Project Settings (nut icon).

char auth[] = "sN-m6mERgFkzdb-W4RLtj5VIwfPJaOzW";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "WiFi-Arnet-4663";
char pass[] = "4166793BE3";

//int pul1 = 6; //derecha
int pul2 = 7;
//int pul3 = 4; //izquierdita
int pul4 = 5;
int LeftPin = 8; //motor
int RightPin = 9; //motor
//int a;
int b;
int MOTOR;
//int c;
int d;
int sw1;
int sw2;
BlynkTimer timer;

void motorDC();
int a;           
int c ;

void setup() {
//pinMode(pul1, INPUT); 
pinMode(pul2, INPUT);
//pinMode(pul3, INPUT); 
pinMode(pul4, INPUT);
pinMode(LeftPin, OUTPUT);
pinMode(RightPin, OUTPUT);

Blynk.begin(auth, ssid, pass);
timer.setInterval(10L, motorDC);
Serial.begin(9600);
MOTOR=0;
sw1=0;
sw2=0;
}

void loop()
{
  Blynk.run();
  timer.run();
}

void motorDC() {
//a = digitalRead(pul1); 
b = digitalRead(pul2);

if(a == LOW && sw1 == 0) 
  { 
    //digitalWrite(b, LOW);
    sw1=1;
    if(MOTOR == 0 && b==HIGH)
    {
      digitalWrite(LeftPin, LOW);
      digitalWrite(RightPin, HIGH); 
      MOTOR=1;
      Serial.println("on");
    }
    else
    {
      digitalWrite(RightPin, LOW);
      digitalWrite(LeftPin, LOW);
      MOTOR=0;
    }
  }
else if(a == HIGH && sw1 == 1)
{
  sw1 = 0;
}

if(MOTOR == 1 && b==LOW)
{
  digitalWrite(RightPin, LOW);
  MOTOR=0;
}

//c = digitalRead(pul3); 
d = digitalRead(pul4);

if(c == LOW && sw2 == 0) 
  { 
    sw2=1;
    if(MOTOR == 0 && d==HIGH)
    {
      digitalWrite(LeftPin, HIGH);
      digitalWrite(RightPin, LOW); 
      MOTOR=1;
      Serial.println("on");
    }
    else
    {
      digitalWrite(RightPin, LOW);
      digitalWrite(LeftPin, LOW);
      MOTOR=0;
    }
  }
else if(c == HIGH && sw2 == 1)
{
  sw2 = 0;
}

if(MOTOR == 1 && d==LOW)
{
  digitalWrite(LeftPin, LOW);
  MOTOR=0;
}

}

BLYNK_WRITE(V7) 
{
a = param.asInt();
}


BLYNK_WRITE(V8) 
{
c = param.asInt();
}

Necesito ayuda para que los pulsadores virtuales V7 Y V8 sean leídos dentro de la función motorDC () y hagan lo que hacían pul1 y pul3 (eran pulsadores físicos)
Quiero que ‘a’ lea el pulsador V7 y cumpla su función dentro de la función motorDC ()
Quiero que ‘c’ lea el pulsador V8 y cumpla su función dentro de la función motorDC ()

The numbers you are using here are GPIO pins, but with the ESP8266 pins 6-11 are reserved GPIOs and not available as physical pins on the board.

Are these meant to be pins D7, D8 and D9 ?

Pete.

#define BLYNK_PRINT Serial
 
#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>


// You should get Auth Token in the Blynk App.

// Go to the Project Settings (nut icon).

char auth[] = "sN-m6mERgFkzdb-W4RLtj5VIwfPJaOzW";
 
// Your WiFi credentials.
// Set password to "" for open networks.
BlynkTimer timer;
char ssid[] = "WiFi-Arnet-4663";
char pass[] = "4166793BE3";

//int pul1 = D6; //derecha
int pul2 = D7;
//int pul3 = D4; //izquierdita
int pul4 = D5;
int LeftPin = D8; //motor
int RightPin = D9; //motor
int a;
int b;
int MOTOR;
int c;
int d;
int sw1;
int sw2;

void setup() {
//pinMode(pul1, INPUT); 
pinMode(pul2, INPUT);
//pinMode(pul3, INPUT); 
pinMode(pul4, INPUT);
pinMode(LeftPin, OUTPUT);
pinMode(RightPin, OUTPUT);

Blynk.begin(auth, ssid, pass);
timer.setInterval(10L, motorDC);
Serial.begin(9600);
MOTOR=0;
sw1=0;
sw2=0;
}

void loop()
{
  Blynk.run();
  timer.run();
}

void motorDC() {
//a = digitalRead(pul1); 
b = digitalRead(pul2);

if(a == LOW && sw1 == 0) 
  { 
    //digitalWrite(b, LOW);
    sw1=1;
    if(MOTOR == 0 && b==HIGH)
    {
      digitalWrite(LeftPin, LOW);
      digitalWrite(RightPin, HIGH); 
      MOTOR=1;
      Serial.println("on");
    }
    else
    {
      digitalWrite(RightPin, LOW);
      digitalWrite(LeftPin, LOW);
      MOTOR=0;
    }
  }
else if(a == HIGH && sw1 == 1)
{
  sw1 = 0;
}

if(MOTOR == 1 && b==LOW)
{
  digitalWrite(RightPin, LOW);
  MOTOR=0;
}

//c = digitalRead(pul3); 
d = digitalRead(pul4);

if(c == LOW && sw2 == 0) 
  { 
    sw2=1;
    if(MOTOR == 0 && d==HIGH)
    {
      digitalWrite(LeftPin, HIGH);
      digitalWrite(RightPin, LOW); 
      MOTOR=1;
      Serial.println("on");
    }
    else
    {
      digitalWrite(RightPin, LOW);
      digitalWrite(LeftPin, LOW);
      MOTOR=0;
    }
  }
else if(c == HIGH && sw2 == 1)
{
  sw2 = 0;
}

if(MOTOR == 1 && d==LOW)
{
  digitalWrite(LeftPin, LOW);
  MOTOR=0;
}

}

BLYNK_WRITE(V7) 
{
a = param.asInt();
}


BLYNK_WRITE(V8) 
{
c = param.asInt();
}

Ahi corregi los pines de la placa.
Lo que me faltaria solucionar es si se pueden leer los pines virtuales (V7 y V8) dentro de la función mortorDC, asi remplazo el pul1 y pul2 por V7 y V8

No, you can’t really read these virtual pins within another function.
The normal process is to assign the virtual pin values to global variables in the BLYNK_WRITE(vPin) callback functions, which is what you are doing.

Why doesn’t this approach work for you?

Pete.

I’ve closed this topic, as you’ve created a new topic about the same piece of code.

Pete.