Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Internet of Things with Blynk

You're reading from   Hands-On Internet of Things with Blynk Build on the power of Blynk to configure smart devices and build exciting IoT projects

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788995061
Length 271 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Pradeeka Seneviratne Pradeeka Seneviratne
Author Profile Icon Pradeeka Seneviratne
Pradeeka Seneviratne
Arrow right icon
View More author details
Toc

Modifying the main.cpp file

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:

  1. 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
  1. Before using the WiringPi GPIO library, you need to include its header file in your program as follows:
#include <wiringPi.h>
  1. 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.

  1. Then, add the following lines to the BLYNK_WRITE(V1...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image