To complete your application, the main.cpp file should also be modified to process the data on the virtual pin. These steps show you how to modify it with the nano editor:
- Open the main.cpp file with nano by issuing the following command:
pi@raspberrypi:~/blynk-library/linux $ sudonanomain.cpp
main.cpp opened with nano editor
- Before using the WiringPi GPIO library, you need to include its header file in your program as follows:
#include <wiringPi.h>
- Scroll down to the file with the arrow keys on your keyboard and add the following code to the setup() function:
void setup()
{
Blynk.begin(auth, serv, port);
pinMode(1, OUTPUT);
}
The pinMode() function allows you to set the mode of a pin to either INPUT, OUTPUT, or PWM_OUTPUT. Note that only WiringPi pin 1 (BCM_GPIO 18) supports PWM output.
- Then, add the following lines to the BLYNK_WRITE(V1...