[blynk.io] Part 2 - Control the LED using Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
[blynk.io] Part 2 - Control the LED using Arduino | |
Board: | |
- Maker UNO | |
https://my.cytron.io/p-maker-uno-simplifying-arduino-for-education?tracking=idris | |
- Arduino Grove Sensor Kit for Beginner | |
https://my.cytron.io/p-arduino-grove-sensor-kit-for-beginner?tracking=idris | |
- Cytron ESP8266 WiFi Shield | |
https://my.cytron.io/p-cytron-esp8266-wifi-shield?tracking=idris | |
Library: | |
- Blynk V1.0.1 | |
Blynk Documentation: | |
- https://docs.blynk.io/en/ | |
Last Modified: 31 Oct 2021 | |
*/ | |
/* Comment this out to disable prints and save space */ | |
#define BLYNK_PRINT Serial | |
/* Fill-in your Template ID (only if using Blynk.Cloud) */ | |
#define BLYNK_TEMPLATE_ID "YourTemplateID" | |
#include <ESP8266_Lib.h> | |
#include <BlynkSimpleShieldEsp8266.h> | |
// You should get Auth Token in the Blynk App. | |
// Go to the Project Settings (nut icon). | |
char auth[] = "YourAuthToken"; | |
// Your WiFi credentials. | |
// Set password to "" for open networks. | |
char ssid[] = "YourNetworkName"; | |
char pass[] = "YourPassword"; | |
// Hardware Serial on Mega, Leonardo, Micro... | |
//#define EspSerial Serial1 | |
// or Software Serial on Uno, Nano... | |
#include <SoftwareSerial.h> | |
SoftwareSerial EspSerial(8, 9); // RX, TX | |
// Your ESP8266 baud rate: | |
#define ESP8266_BAUD 9600 | |
#define LED 6 | |
ESP8266 wifi(&EspSerial); | |
BLYNK_WRITE(V0) | |
{ | |
int pinValue = param.asInt(); | |
digitalWrite(LED, pinValue); | |
} | |
void setup() | |
{ | |
pinMode(LED, OUTPUT); | |
// Debug console | |
Serial.begin(9600); | |
delay(10); | |
// Set ESP8266 baud rate | |
EspSerial.begin(ESP8266_BAUD); | |
delay(10); | |
Blynk.begin(auth, wifi, ssid, pass); | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment