Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. /*************************************************************
  2. Download latest Blynk library here:
  3. https://github.com/blynkkk/blynk-library/releases/latest
  4.  
  5. Blynk is a platform with iOS and Android apps to control
  6. Arduino, Raspberry Pi and the likes over the Internet.
  7. You can easily build graphic interfaces for all your
  8. projects by simply dragging and dropping widgets.
  9.  
  10. Downloads, docs, tutorials: http://www.blynk.cc
  11. Sketch generator: http://examples.blynk.cc
  12. Blynk community: http://community.blynk.cc
  13. Follow us: http://www.fb.com/blynkapp
  14. http://twitter.com/blynk_app
  15.  
  16. Blynk library is licensed under MIT license
  17. This example code is in public domain.
  18.  
  19. *************************************************************
  20.  
  21. This sketch shows how to write values to Virtual Pins
  22.  
  23. NOTE:
  24. BlynkTimer provides SimpleTimer functionality:
  25. http://playground.arduino.cc/Code/SimpleTimer
  26.  
  27. App project setup:
  28. Value Display widget attached to Virtual Pin V5
  29. *************************************************************/
  30.  
  31. /* Comment this out to disable prints and save space */
  32. #define BLYNK_PRINT stdout
  33.  
  34. #ifdef RASPBERRY
  35. #include <BlynkApiWiringPi.h>
  36. #else
  37. #include <BlynkApiLinux.h>
  38. #endif
  39. #include <BlynkSocket.h>
  40. #include <BlynkOptionsParser.h>
  41.  
  42. static BlynkTransportSocket _blynkTransport;
  43. BlynkSocket Blynk(_blynkTransport);
  44. #include <BlynkWidgets.h>
  45.  
  46. BlynkTimer timer;
  47.  
  48. // This function sends Arduino's up time every second to Virtual Pin (5).
  49. // In the app, Widget's reading frequency should be set to PUSH. This means
  50. // that you define how often to send data to Blynk App.
  51. void myTimerEvent()
  52. {
  53. // You can send any value at any time.
  54. // Please don't send more that 10 values per second.
  55. Blynk.virtualWrite(V5, millis() / 1000);
  56. }
  57.  
  58. void setup()
  59. {
  60. // Setup a function to be called every second
  61. timer.setInterval(1000L, myTimerEvent);
  62. }
  63.  
  64. void loop()
  65. {
  66. Blynk.run();
  67. timer.run(); // Initiates BlynkTimer
  68. }
  69.  
  70. int main(int argc, char* argv[])
  71. {
  72. const char *auth, *serv;
  73. uint16_t port;
  74. parse_options(argc, argv, auth, serv, port);
  75.  
  76. Blynk.begin(auth, serv, port);
  77.  
  78. setup();
  79. while(true) {
  80. loop();
  81. }
  82.  
  83. return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement