-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathswitch_shoes.ino
112 lines (95 loc) · 9.75 KB
/
switch_shoes.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <WiFi.h>
#include <WebServer.h>
#include <Adafruit_NeoPixel.h>
//ステーションモード設定
#define SSID "led_wifi"
#define PASSWORD "00000000"
const char *ssid = SSID;
const char *password = PASSWORD;
WebServer server(80);
// LEDテープ設定
#define PIN 21 // M5Stack Grobe Pin
#define NUMPIXELS 256 // Enough for 29 LEDs
#define DELAYVAL 10 // Time (in milliseconds) to pause between pixels
int led_color[3][3] ={{10,0,0},{0,10,0},{0,0,10}};
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int matselect = 1;
bool isPending = true;
byte mat1[256][3] = {{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0},{31,0,0}};
byte mat2[256][3] = {{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31},{0,0,31}};
byte mat3[256][3] = {{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31},{31,31,31}};
void handleRoot() {
server.send(200, "text/html", "<h1>Please access /mat1, /mat2 or /mat3</h1>");
}
void handleMat1() {
matselect = 1;
isPending = true;
Serial.println("MAT1");
server.send(200, "text/html", "LED ON");
}
void handleMat2() {
matselect = 2;
isPending = true;
Serial.println("MAT2");
server.send(200, "text/html", "LED ON");
}
void handleMat3() {
matselect = 0;
isPending = true;
Serial.println("MAT3");
server.send(200, "text/html", "LED OFF");
}
void setup() {
delay(1000);
Serial.begin(115200);
// WiFiステーションモード
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connecred to ");
Serial.println(ssid);
Serial.print("IP address");
Serial.println(WiFi.localIP());
// LEDテープ設定
pixels.begin();
server.on("/", handleRoot);
server.on("/mat1", handleMat1);
server.on("/mat2", handleMat2);
server.on("/mat3", handleMat3);
server.begin();
}
void loop() {
server.handleClient();
if(isPending) {
if(matselect == 1) {
pixels.clear();
for(int i=0; i<NUMPIXELS; i++) {
int rgb = i%3;
pixels.setPixelColor(i, pixels.Color(mat1[i][0],mat1[i][1],mat1[i][2]));
pixels.show();
delay(DELAYVAL);
}
} else if(matselect == 2) {
pixels.clear();
for(int i=0; i<NUMPIXELS; i++) {
int rgb = i%3;
pixels.setPixelColor(i, pixels.Color(mat2[i][0],mat2[i][1],mat2[i][2]));
pixels.show();
delay(DELAYVAL);
}
} else {
pixels.clear();
for(int i=0; i<NUMPIXELS; i++) {
int rgb = i%3;
pixels.setPixelColor(i, pixels.Color(mat3[i][0],mat3[i][1],mat3[i][2]));
pixels.show();
delay(DELAYVAL);
}
}
}
isPending = false;
}