first commit
This commit is contained in:
65
libraries/Blynk/examples/Widgets/Joystick/Joystick.ino
Normal file
65
libraries/Blynk/examples/Widgets/Joystick/Joystick.ino
Normal file
@@ -0,0 +1,65 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
You can receive x and y coords for joystick movement within App.
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V0, type: String
|
||||
|
||||
App dashboard setup:
|
||||
Add Joystick widget, select mode: Advanced, attach it V0
|
||||
|
||||
NOTE: Advanced mode means device will receive both x and y on a single Datastream
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
BLYNK_WRITE(V0) {
|
||||
int x = param[0].asInt();
|
||||
int y = param[1].asInt();
|
||||
|
||||
// Do something with x and y
|
||||
Serial.print("X = ");
|
||||
Serial.print(x);
|
||||
Serial.print("; Y = ");
|
||||
Serial.println(y);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Output any data on LCD widget!
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V9, type: String
|
||||
|
||||
App dashboard setup:
|
||||
LCD widget, switch to ADVANCED mode, attach it to V9
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
WidgetLCD lcd(V9);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
lcd.clear(); //Use it to clear the LCD Widget
|
||||
lcd.print(4, 0, "Hello"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
|
||||
lcd.print(4, 1, "World");
|
||||
// Please use timed events when LCD printintg in void loop to avoid sending too many commands
|
||||
// It will cause a FLOOD Error, and connection will be dropped
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Output any data on LCD widget!
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V8, type: Integer, min: 0, max: 10000
|
||||
Virtual Pin V9, type: Integer, min: 0, max: 10000000
|
||||
|
||||
App dashboard setup:
|
||||
LCD widget, SIMPLE mode. In Settings tab:
|
||||
- Attach V8 to first line
|
||||
- Attach V9 to second line
|
||||
Switch to Design tab:
|
||||
- Set first line message to: "/value1/ seconds"
|
||||
- Set second line message to: "/value2/ ms"
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
BlynkTimer timer;
|
||||
|
||||
void sendSeconds() {
|
||||
Blynk.virtualWrite(V8, millis() / 1000);
|
||||
}
|
||||
|
||||
void sendMillis() {
|
||||
Blynk.virtualWrite(V9, millis());
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
// Setup a function to be called every second
|
||||
timer.setInterval(1000L, sendSeconds);
|
||||
// Setup a function to be called every second
|
||||
timer.setInterval(1000L, sendMillis);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
timer.run();
|
||||
}
|
||||
|
||||
71
libraries/Blynk/examples/Widgets/LED/LED_Blink/LED_Blink.ino
Normal file
71
libraries/Blynk/examples/Widgets/LED/LED_Blink/LED_Blink.ino
Normal file
@@ -0,0 +1,71 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Blynk using a LED widget on your phone!
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V3, type: Integer, min: 0, max: 255
|
||||
|
||||
App/Web dashboard setup:
|
||||
LED widget on V3
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
WidgetLED led1(V3);
|
||||
|
||||
BlynkTimer timer;
|
||||
|
||||
// V3 LED Widget is blinking
|
||||
void blinkLedWidget()
|
||||
{
|
||||
if (led1.getValue()) {
|
||||
led1.off();
|
||||
Serial.println("LED on V3: off");
|
||||
} else {
|
||||
led1.on();
|
||||
Serial.println("LED on V3: on");
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
timer.setInterval(1000L, blinkLedWidget);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
timer.run();
|
||||
}
|
||||
|
||||
86
libraries/Blynk/examples/Widgets/LED/LED_Color/LED_Color.ino
Normal file
86
libraries/Blynk/examples/Widgets/LED/LED_Color/LED_Color.ino
Normal file
@@ -0,0 +1,86 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Blynk using a LED widget on your phone!
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V3, type: Integer, min: 0, max: 255
|
||||
|
||||
App/Web dashboard setup:
|
||||
LED widget on V3
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
WidgetLED led1(V3);
|
||||
|
||||
BlynkTimer timer;
|
||||
bool ledStatus = false;
|
||||
|
||||
#define BLYNK_GREEN "#23C48E"
|
||||
#define BLYNK_BLUE "#04C0F8"
|
||||
#define BLYNK_YELLOW "#ED9D00"
|
||||
#define BLYNK_RED "#D3435C"
|
||||
#define BLYNK_DARK_BLUE "#5F7CD8"
|
||||
|
||||
BLYNK_CONNECTED() {
|
||||
// Turn LED on, so colors are visible
|
||||
led1.on();
|
||||
}
|
||||
|
||||
// V3 LED Widget is blinking
|
||||
void blinkLedWidget()
|
||||
{
|
||||
if (ledStatus) {
|
||||
led1.setColor(BLYNK_RED);
|
||||
Serial.println("LED on V3: red");
|
||||
ledStatus = false;
|
||||
} else {
|
||||
led1.setColor(BLYNK_GREEN);
|
||||
Serial.println("LED on V3: green");
|
||||
ledStatus = true;
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
// Setup periodic color change
|
||||
timer.setInterval(1000L, blinkLedWidget);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
timer.run();
|
||||
}
|
||||
|
||||
74
libraries/Blynk/examples/Widgets/LED/LED_Fade/LED_Fade.ino
Normal file
74
libraries/Blynk/examples/Widgets/LED/LED_Fade/LED_Fade.ino
Normal file
@@ -0,0 +1,74 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Fade using a LED widget on your phone!
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V3, type: Integer, min: 0, max: 255
|
||||
|
||||
App/Web dashboard setup:
|
||||
LED widget on V3
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
WidgetLED led1(V3);
|
||||
|
||||
BlynkTimer timer;
|
||||
|
||||
// V3 LED Widget is fading
|
||||
void fadeLedWidget()
|
||||
{
|
||||
static int value = 0;
|
||||
static int delta = 30;
|
||||
value += delta;
|
||||
if (value > 255 || value < 0) {
|
||||
delta = -delta;
|
||||
} else {
|
||||
Serial.print("LED on V3: ");
|
||||
Serial.println(value);
|
||||
led1.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
timer.setInterval(300L, fadeLedWidget);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
timer.run();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Blynk using a LED widget on your phone!
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V3, type: Integer, min: 0, max: 255
|
||||
|
||||
App/Web dashboard setup:
|
||||
LED widget on V3
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
// Select your pin with physical button
|
||||
const int btnPin = 4;
|
||||
|
||||
WidgetLED led1(V3);
|
||||
|
||||
BlynkTimer timer;
|
||||
|
||||
// V3 LED Widget represents the physical button state
|
||||
boolean btnState = false;
|
||||
void buttonLedWidget()
|
||||
{
|
||||
// Read button
|
||||
boolean isPressed = (digitalRead(btnPin) == LOW);
|
||||
|
||||
// If state has changed...
|
||||
if (isPressed != btnState) {
|
||||
if (isPressed) {
|
||||
led1.on();
|
||||
} else {
|
||||
led1.off();
|
||||
}
|
||||
btnState = isPressed;
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
// Setup physical button pin (active low)
|
||||
pinMode(btnPin, INPUT_PULLUP);
|
||||
|
||||
timer.setInterval(500L, buttonLedWidget);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
timer.run();
|
||||
}
|
||||
|
||||
66
libraries/Blynk/examples/Widgets/Map/Map.ino
Normal file
66
libraries/Blynk/examples/Widgets/Map/Map.ino
Normal file
@@ -0,0 +1,66 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Output any data on Map widget!
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V6, type: String
|
||||
|
||||
App dashboard setup:
|
||||
Map widget on V6
|
||||
|
||||
NOTE: This is for the App Map widget only.
|
||||
The Web Dashboard has different functionality. Read More:
|
||||
https://docs.blynk.io/en/blynk.console/widgets-console/map
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
WidgetMap myMap(V6);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
// If you want to remove all points:
|
||||
//myMap.clear();
|
||||
|
||||
int index = 0;
|
||||
double lat = 50.4495378;
|
||||
double lon = 30.5251447;
|
||||
myMap.location(index, lat, lon, "Monument of Independence");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
74
libraries/Blynk/examples/Widgets/Menu/Menu.ino
Normal file
74
libraries/Blynk/examples/Widgets/Menu/Menu.ino
Normal file
@@ -0,0 +1,74 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
This example shows how to use the Menu Widget.
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V1, type: Integer, min: 1, max: 3
|
||||
|
||||
App/Web dashboard setup:
|
||||
Menu widget attached to V1 (put 3 items in it)
|
||||
|
||||
For Integer DS, pay attention to the Datastream range.
|
||||
Apps automatically assign values to the menu items,
|
||||
starting with the minimal datastream value.
|
||||
It's also possible to use Enum datastreams.
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
BLYNK_WRITE(V1) {
|
||||
switch (param.asInt())
|
||||
{
|
||||
case 1: // Item 1
|
||||
Serial.println("Item 1 selected");
|
||||
break;
|
||||
case 2: // Item 2
|
||||
Serial.println("Item 2 selected");
|
||||
break;
|
||||
case 3: // Item 3
|
||||
Serial.println("Item 3 selected");
|
||||
break;
|
||||
default:
|
||||
Serial.println("Unknown item selected");
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
74
libraries/Blynk/examples/Widgets/MusicPlayer/MusicPlayer.ino
Normal file
74
libraries/Blynk/examples/Widgets/MusicPlayer/MusicPlayer.ino
Normal file
@@ -0,0 +1,74 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
This example shows how you can process commands from player widget
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V5, type: String
|
||||
|
||||
App dashboard setup:
|
||||
Music Player widget on V5
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
BLYNK_WRITE(V5)
|
||||
{
|
||||
String action = param.asStr();
|
||||
|
||||
if (action == "play") {
|
||||
// Do something
|
||||
}
|
||||
if (action == "stop") {
|
||||
// Do something
|
||||
}
|
||||
if (action == "next") {
|
||||
// Do something
|
||||
}
|
||||
if (action == "prev") {
|
||||
// Do something
|
||||
}
|
||||
|
||||
Blynk.setProperty(V5, "label", action);
|
||||
Serial.print(action);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
87
libraries/Blynk/examples/Widgets/Terminal/Terminal.ino
Normal file
87
libraries/Blynk/examples/Widgets/Terminal/Terminal.ino
Normal file
@@ -0,0 +1,87 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
You can send/receive any data using WidgetTerminal object.
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V10, type: String
|
||||
|
||||
App/Web dashboard setup:
|
||||
Terminal widget on V10
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
// Attach virtual serial terminal to Virtual Pin V10
|
||||
WidgetTerminal terminal(V10);
|
||||
|
||||
// You can send commands from Terminal to your hardware. Just use
|
||||
// the same Virtual Pin as your Terminal Widget
|
||||
BLYNK_WRITE(V10)
|
||||
{
|
||||
|
||||
// if you type "Marco" into Terminal Widget - it will respond: "Polo:"
|
||||
if (String("Marco") == param.asStr()) {
|
||||
terminal.println("You said: 'Marco'") ;
|
||||
terminal.println("I said: 'Polo'") ;
|
||||
} else {
|
||||
|
||||
// Send it back
|
||||
terminal.print("You said:");
|
||||
terminal.write(param.getBuffer(), param.getLength());
|
||||
terminal.println();
|
||||
}
|
||||
|
||||
// Ensure everything is sent
|
||||
terminal.flush();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
|
||||
// Clear the terminal content
|
||||
terminal.clear();
|
||||
|
||||
// This will print Blynk Software version to the Terminal Widget when
|
||||
// your hardware gets connected to Blynk Server
|
||||
terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
|
||||
terminal.println(F("-------------"));
|
||||
terminal.println(F("Type 'Marco' and get a reply, or type"));
|
||||
terminal.println(F("anything else and get it printed back."));
|
||||
terminal.flush();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V1, type: String
|
||||
|
||||
App dashboard setup:
|
||||
Time Input widget on V1
|
||||
Change format to HH:MM:SS
|
||||
Allow start/stop input -> YES
|
||||
Allow day of week selections -> YES
|
||||
Allow sunset/sunrise selections -> YES
|
||||
Allow timezone selection -> YES
|
||||
|
||||
On a running device, tap on the widget to select:
|
||||
Day(s) of the week, start/end time (or sunrise/sunset), and timezone
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
BLYNK_WRITE(V1) {
|
||||
TimeInputParam t(param);
|
||||
|
||||
// Process start time
|
||||
|
||||
if (t.hasStartTime())
|
||||
{
|
||||
Serial.println(String("Start: ") +
|
||||
t.getStartHour() + ":" +
|
||||
t.getStartMinute() + ":" +
|
||||
t.getStartSecond());
|
||||
}
|
||||
else if (t.isStartSunrise())
|
||||
{
|
||||
Serial.println("Start at sunrise");
|
||||
}
|
||||
else if (t.isStartSunset())
|
||||
{
|
||||
Serial.println("Start at sunset");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Process stop time
|
||||
|
||||
if (t.hasStopTime())
|
||||
{
|
||||
Serial.println(String("Stop: ") +
|
||||
t.getStopHour() + ":" +
|
||||
t.getStopMinute() + ":" +
|
||||
t.getStopSecond());
|
||||
}
|
||||
else if (t.isStopSunrise())
|
||||
{
|
||||
Serial.println("Stop at sunrise");
|
||||
}
|
||||
else if (t.isStopSunset())
|
||||
{
|
||||
Serial.println("Stop at sunset");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do nothing: no stop time was set
|
||||
}
|
||||
|
||||
// Process timezone
|
||||
// Timezone is already added to start/stop time
|
||||
|
||||
Serial.println(String("Time zone: ") + t.getTZ());
|
||||
|
||||
// Get timezone offset (in seconds)
|
||||
Serial.println(String("Time zone offset: ") + t.getTZ_Offset());
|
||||
|
||||
// Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
|
||||
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
if (t.isWeekdaySelected(i)) {
|
||||
Serial.println(String("Day ") + i + " is selected");
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V1, type: String
|
||||
|
||||
App dashboard setup:
|
||||
Time Input widget on V1 with only start time option
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
BLYNK_WRITE(V1) {
|
||||
long startTimeInSecs = param[0].asLong();
|
||||
Serial.println(startTimeInSecs);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*************************************************************
|
||||
Blynk is a platform with iOS and Android apps to control
|
||||
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
||||
You can easily build mobile and web interfaces for any
|
||||
projects by simply dragging and dropping widgets.
|
||||
|
||||
Downloads, docs, tutorials: https://www.blynk.io
|
||||
Sketch generator: https://examples.blynk.cc
|
||||
Blynk community: https://community.blynk.cc
|
||||
Follow us: https://www.fb.com/blynkapp
|
||||
https://twitter.com/blynk_app
|
||||
|
||||
Blynk library is licensed under MIT license
|
||||
This example code is in public domain.
|
||||
|
||||
*************************************************************
|
||||
|
||||
Datastream setup:
|
||||
Virtual Pin V1, type: String
|
||||
|
||||
App dashboard setup:
|
||||
Time Input widget on V1
|
||||
*************************************************************/
|
||||
|
||||
/* Comment this out to disable prints and save space */
|
||||
#define BLYNK_PRINT Serial
|
||||
|
||||
/* Fill in information from Blynk Device Info here */
|
||||
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
||||
//#define BLYNK_TEMPLATE_NAME "Device"
|
||||
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
||||
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <BlynkSimpleEthernet.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Debug console
|
||||
Serial.begin(9600);
|
||||
|
||||
Blynk.begin(BLYNK_AUTH_TOKEN);
|
||||
}
|
||||
|
||||
//as soon as connected update TimeInput widget state
|
||||
BLYNK_CONNECTED() {
|
||||
//seconds from the start of a day. 0 - min, 86399 - max
|
||||
int startAt = 5 * 60; //00:05
|
||||
|
||||
//seconds from the start of a day. 0 - min, 86399 - max
|
||||
int stopAt = (60 + 5) * 60; //01:05
|
||||
|
||||
//timezone
|
||||
//full list of supported timezones could be found here
|
||||
//https://www.mkyong.com/java/java-display-list-of-timezone-with-gmt/
|
||||
char tz[] = "Europe/Kiev";
|
||||
|
||||
Blynk.virtualWrite(V1, startAt, stopAt, tz);
|
||||
|
||||
//you may also pass day
|
||||
//char days[] = "1"; //Monday
|
||||
//Blynk.virtualWrite(V1, startAt, stopAt, tz, days);
|
||||
|
||||
//or days
|
||||
//char days[] = "1,2,3"; //Monday, Tuesday, Wednesday
|
||||
//Blynk.virtualWrite(V1, startAt, stopAt, tz, days);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Blynk.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user