-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp8266_code.ino
53 lines (41 loc) · 1.39 KB
/
esp8266_code.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*login on Sign up a new account in Blynk using your email id.
Click on Create New Project,choosed device esp8266 and click create.
The auth token for this project will be delivered to your email.Replace the auth token in program with your auth token.
create a button,edit and change its PIN to (Digital) D6.
*/
#include <Blynk.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "a624256ad4ab4d548ff5f210f3d6fe6a"; //Auth Token for WiM automation project provided by Blynk
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "adiljio"; //Replace with ssid(wifi name) of your home wifi hotspot
char pass[] = "8281537265"; //Replace with wpa2 password of your home wifi hotspot
int ledPin = 2;
int buttonPin = 12;
int buttonState = 0;
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop()
{
Blynk.run();
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}