Introduction: How to Use Virtual Pins in Blynk

Hello Everyone. I was tinkering with the blynk app and wanted to find a way to use the virtual pins.. Here is what I came up with so far...
Essentially this project uses and LDR attached to adc pin to switch on a virtual LED in the blynk app as a notification. I am hoping that when further widgets and more features such as MQTT, Thingspeak, IFTTT are added, this can come in handy to make easy projects such as alarms, irrigation timers, home automation etc.

Step 1: Tools

Hardware:

ESP8266 development board. I am using ESP-12 with and LDR attached to ADC pin.

Software:

Arduino IDE with required libraries(blynk, esp8266com etc)

Here is a step- by step guide how to set up https://www.instructables.com/id/ESP8266-ESP-12Stan...

Blynk app

Step 2: Virtual Pins

Virtual pins are used to interface with libraries (Servo, LCD and others), and implement custom functionality.The device may send data to the widget on a virtual pin like this:

* Blynk.virtualWrite(pin, "abc");
* Blynk.virtualWrite(pin, 123);
* Blynk.virtualWrite(pin, 12.34);

Also, virtual pins can react to value updates and requests. For example, this function will be called every time App Widget requests data for Virtual Pin 5:
* BLYNK_READ(5) { // Usually, you will need to respond with a virtual pin value. Blynk.virtualWrite(5, some_value); }

This function will be called every time App Widget writes value to Virtual Pin 1:
* BLYNK_WRITE(1) { BLYNK_LOG("Got a value: %s", param.asStr()); // You can also use: param.asInt() and param.asDouble() }

BLYNK_READ/BLYNK_WRITE functions are effectively "getters/setters" of the Virtual Pins if you're familiar with this concept in other programming languages. Please also take into account that these functions should take minimal time to execute, so avoid using sleep/delay inside of them.
N.B: taken from readme doc https://github.com/blynkkk/blynk-library/blob/mast...

Essentially i wanted to make an example to illustrate the BASIC use of the Blynk.virtualWrite() command
I made a sketch in Arduino:
the value of adc pin is read and when value <100, a HIGH is written to virtual pin 5.
the magic then happens in the blynk app where I can also visualise the adc analog value and light an LED when ldr analog value <100

Step 3: Results

As you can see in the pictures:
when LDR value is >100 the Burglar LED pin is switched off
When I shine a light on LDR, ldrvalue<100 LED is swtiched on

This is just a proof of concept.. With more tinkering I guess this can come in handy..