Now we compare it if we receive 1 means HIGH integer from the V0 pin when we press the switch from our web dashboard or blynk mobile app. Then we digitally high the D2 number pin by using the digital write command.
int s0 = param.asInt(); // parameter as int
if(s0 == HIGH)
{
digitalWrite(D2,HIGH);
delay(10);
}
Similarly, if we receive the LOW or 0 integers, then we digitally Low the D2 pin. We connect the led at the D2 number pin of Nuttyfi.
if(s0 == LOW)
{
digitalWrite(D2,LOW);
delay(10);
}
Below is the setup function, we begin the serial at a 9600 baud rate. Define the pinMode for D2 pin as input and digitally Low the D2 pin in the starting. Here we begin the blynkagent. In the loop function, there is only one function, Blynk Edgent.run
When an event will happen in the blynk mobile app or the blynk web dashboard, it will automatically call that event.
Now, we connect the Nuttyfi/ NodeMCU board to our laptop to program it. We should have a wifi board installed into our Arduino IDE. If you don’t know how to install a wifi board, then this is a link to describe to you, how you can install it to the Arduino IDE.
i am using here ESP8266 Nuttyfi wifi development Board, Developed by Nutty Engineer Company, It is the most powerful board with the latest firmware. You can use nodemcu or other wifi development boards beside it.
So you go to the tools tab->, then Boards-> select NodeMCU 1.0 ESP12E Module board and PORT as COM8, and upload the program. And it’s done.
Now, you need to downlaod the new Blynk IoT app. go to your play store/ app store, search blynk here and you can see here blynk IoT New app. You just download it.
So, open and login to the app. Click on add new device and It displays the 3 options:
- Connect to wifi
- Scan QR code
- Quick start Device
Click on “Connect to wifi” option.