-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathesp_wifi.ino
50 lines (39 loc) · 1.25 KB
/
esp_wifi.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
/* This example is written for Nodemcu Modules */
#include "ESP_Wahaj.h" // importing our library
# define led D4
int pwm = 255;
String path = "nothing";
void setup(){
Serial.begin(9600);
start("ssid","password"); // Wifi details connect to
}
void loop(){
//waitUntilNewReq(); //Waits until a new request from python come
if(CheckNewReq() == 1)
{
//Serial.println("new request");
if (getPath()=="/two"){
returnThisStr("two replied");
}
else if (getPath()=="/one"){
returnThisStr("one replied");
}
else if(getPath()=="/favicon.ico"){ //this happens for browsers only.
returnThisStr("garbage");
}
else //here we receive data. You can receive pwm255 and the decode it to 255 and also get more variables like this
{
path = getPath();
Serial.println(path); //String
//returnThisStr("nothing");
path.remove(0,1); //Remove slash /
Serial.println(path);
pwm = path.toInt(); //convert to int you can use toFloat()
Serial.println(pwm);
}
}
//Serial.println("tesiting....");
//if(pwm == 255) Serial.println("highhhhh");
//if(pwm == 0) Serial.println("lowwwwsssh");
//analogWrite(led,pwm);
}