The Value Display widget also supports virtual pins. Follow these steps to configure the Value Display widget with a virtual pin:
- Tap the stop button to stop the application and go back to the canvas.
- Tap the Value Display widget to open the Value Display Settings page.
- Under INPUT, tap gpio 18 PWM. From the left-hand side list, select Virtual, and from the right-hand side list, select V1.
- Tap OK. Now, your Value Display Settings page should look like the following (see the following screenshot):
Value Display settings for a virtual pin
- Tap the back button on the toolbar to go to the canvas page. Now, you can see the Value Display widget is configured with the virtual pin V1.
- Modify the main.cpp file as shown in Listing 4.2 (https://github.com/PacktPublishing/Hands-On-Internet-of-Things-with-Blynk/blob/master/Chapter%204/Listing%204-2/main.cpp). Use the commands in the previous section to locate and open the file.
- Save and exit the editor by pressing Ctrl + O, followed by Enter, followed by Ctrl + X.
- Build the C++ project using this command:
pi@raspberrypi:~/blynk-library/linux $ ./build.sh raspberry
- Run the C++ project using this command, with the auth token associated with your Blynk application:
pi@raspberrypi:~/blynk-library/linux $sudo ./blynk --token=ca7bed1c92214503a65de8e20164994f
- Now, tap the play button to start the app. The Value Display widget will show the analog reading value of the potentiometer. You can take potentiometer values between 0 and 1023.