Copy and Paste from the Blynk Example Browser
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
Simple push notification example
App project setup:
Push widget
Connect a button to pin 2 and GND...
Pressing this button will also push a message! ;)
*************************************************************/
/* Comment this out to disable prints and save space */
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
#include <BlynkApiWiringPi.h>
#else
#include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>
static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);
#include <BlynkWidgets.h>
BlynkTimer timer;
void notifyUptime()
{
long uptime = millis() / 60000L;
// Actually send the message.
// Note:
// We allow 1 notification per 15 seconds for now.
Blynk.notify(String("Running for ") + uptime + " minutes.");
}
void setup()
{
// Notify immediately on startup
Blynk.notify("Device started");
// Setup a function to be called every minute
timer.setInterval(60000L, notifyUptime);
}
void loop()
{
Blynk.run();
timer.run();
}
int main(int argc, char* argv[])
{
const char *auth, *serv;
uint16_t port;
parse_options(argc, argv, auth, serv, port);
Blynk.begin(auth, serv, port);
setup();
while(true) {
loop();
}
return 0;
}
```cpp