Secondary Menu

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.

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() commandI 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

It doesn't works i have usb connectivity only.please give any solution .i just want led indication. i have connected led to digital pin 6.and pin 6 also connected to analog pin a0.i have using same code just editing that analog=anlogRead(irec)if(anlog= HIGH){VirtualWrite(5, HIGH);}else{ virtualwrite(5, LOW);}when program is running then led is on /off by Blynk it doesn't show indication of led on blynk.