BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How to flashing 2 physical LED of mobile Robot

esp8266
arduino

#1

Hi guys,
Im building a mobile control car using wifi and arduino. The problem is to make the physical LEDs (signal indicator) flashing when the virtual button is pressed.

The mobile robot consists of:-
Arduino Nano
ESP-01 ESP8266
Logic Converter
L298N motor Driver
LEDs (Headlight, Taillight, Signal)

Android 8.1

The headlight and the taillight working well through directly assigned pin on the app. Only the signal indicator is not flashing.

#define BLYNK_PRINT Serial

#include<ESP8266_Lib.h>
#include<BlynkSimpleShieldEsp8266.h>

char auth[] = "XXXX"; 

char ssid[] = "XXXX";
char pass[] = "XXXX";

#include<SoftwareSerial.h>
SoftwareSerial EspSerial (2, 3); // here RX, TX

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

#define led1 A0 //
#define led2 A1 //
int ledState = LOW; //
const long interval = 400; //
unsigned long previousMillis = 0; //

void setup() 
{
  pinMode(led1, OUTPUT); //
  pinMode(led2, OUTPUT); //
  Serial.begin(9600);
  delay(10);

   EspSerial.begin(ESP8266_BAUD);
   delay(10);

   Blynk.begin(auth, wifi, ssid, pass);
}

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


BLYNK_WRITE(V0)
  {
    if (param.asInt() == 1)
    {
      unsigned long currentMillis = millis();
      if (currentMillis - previousMillis >= interval)
      {
        previousMillis = currentMillis;

        if (ledState == LOW)
        {
          ledState = HIGH;
        }
        else
        {
          ledState = LOW;
        }

        digitalWrite(led1, ledState);
        digitalWrite(led2, !ledState);
      }
    }
    else 
    {
      digitalWrite(led1, LOW);
      digitalWrite(led2, LOW);
    }
}



#2

You might want to look at using Virtual pins…

Look at how this is done and change for Physical LEDs if you need.


#3

The Signal LED is connected to the analog pin and it is set to blinking when the virtual pin (V0) is pressed. But code for the blinking have the problem.

I will try to change it to physical led


#4

I ment use virtual pins for everything on the App, not a mixture of direct pin control and virtual pin control.


#5

Will try to change all the pin to virtual and update it :grinning: