sunu

Blynk 5 LED array

Jul 18th, 2022 (edited)
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   This example runs directly on ESP8266 chip.
  21.  
  22.   Note: This requires ESP8266 support package:
  23.     https://github.com/esp8266/Arduino
  24.  
  25.   Please be sure to select the right ESP8266 module
  26.   in the Tools -> Board menu!
  27.  
  28.   Change WiFi ssid, pass, and Blynk auth token to run :)
  29.   Feel free to apply it to any other example. It's simple!
  30.  *************************************************************/
  31.  
  32. /* Comment this out to disable prints and save space */
  33. //#define BLYNK_PRINT Serial
  34.  
  35. #define BLYNK_TEMPLATE_ID "isiDenganPengenalTemplate"
  36. #define BLYNK_DEVICE_NAME "Uji baris LED Dev 01"
  37. #define BLYNK_AUTH_TOKEN "isiDenganAuthToken"
  38.  
  39. #include <ESP8266WiFi.h>
  40. #include <BlynkSimpleEsp8266.h>
  41.  
  42. char auth[] = BLYNK_AUTH_TOKEN;
  43.  
  44. // Your WiFi credentials.
  45. // Set password to "" for open networks.
  46. char ssid[] = "mySSID";//Enter your WIFI name
  47. char pass[] = "myPASS";//Enter your WIFI password
  48.  
  49. BlynkTimer timer;
  50. WidgetLED led1(V4);
  51.  
  52. BLYNK_WRITE(V0){
  53.  int pinValue = param.asInt();
  54.  digitalWrite(16, pinValue);
  55. }
  56. BLYNK_WRITE(V1){
  57.  int pinValue = param.asInt();
  58.  digitalWrite(5, pinValue);
  59. }
  60. BLYNK_WRITE(V2){
  61.  int pinValue = param.asInt();
  62.  digitalWrite(4, pinValue);
  63. }
  64.  
  65. BLYNK_WRITE(V3){
  66.  int pinValue = param.asInt();
  67.  digitalWrite(0, pinValue);
  68. }
  69.  
  70. void bacaD5(){
  71.   int val_D5 = digitalRead(14);
  72.   if(val_D5 == HIGH){
  73.     led1.on();
  74.   }
  75.   else{
  76.     led1.off();
  77.   }  
  78. }
  79.  
  80. void setup()
  81. {
  82.   // Debug console
  83.   //Serial.begin(9600);
  84.   pinMode(14, INPUT); //D5 GPIO14
  85.   pinMode(16, OUTPUT); //D0 GPIO16
  86.   pinMode(5, OUTPUT);  //D1 GPIO5
  87.   pinMode(4, OUTPUT);  //D2 GPIO4
  88.   pinMode(0, OUTPUT);  //D3 GPIO0
  89.   pinMode(2, OUTPUT);  //D2 GPIO2
  90.   digitalWrite(16, HIGH); //Hanya dipakai untuk display LED
  91.   digitalWrite(2, HIGH); //Hanya dipakai untuk display LED  
  92.   Blynk.begin(auth, ssid, pass);
  93.   timer.setInterval(1000L, bacaD5);
  94. }
  95.  
  96. void loop()
  97. {
  98.   Blynk.run();
  99.   timer.run();
  100. }
  101.  
Add Comment
Please, Sign In to add comment