first commit
This commit is contained in:
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user