1
0
Fork 0
mirror of https://github.com/kou029w/k2ping.git synced 2025-01-18 16:07:59 +00:00

LCDにWi-Fi接続状況を表示する

This commit is contained in:
Nebel 2017-04-15 13:06:48 +09:00
parent 7e41937968
commit 438756b0f3

View file

@ -1,25 +1,40 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <Wire.h>
#include <LiquidCrystal.h>
// Digital pins for WeMos D1 // Digital pins for WeMos D1
static const uint8_t D[] = {3, 1, 16, 5, 4, 14, 12, 13, 0, 2, 15}; static const uint8_t D[] = {3, 1, 16, 5, 4, 14, 12, 13, 0, 2, 15};
// LCD Keypad Shield for Arduino
LiquidCrystal lcd(D[8], D[9], D[4], D[5], D[6], D[7]);
void setup() { void setup() {
Serial.begin(9600); lcd.begin(16, 2);
Serial.println();
WiFi.begin("network-name", "pass-to-network"); WiFi.begin("network-name", "pass-to-network");
Serial.print("Connecting"); lcd.print("Connecting");
lcd.setCursor(0, 1);
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
delay(500); delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: "); static uint8_t i = 0;
Serial.println(WiFi.localIP()); lcd.setCursor((i %= 32) % 16, 1);
if (i < 16) {
lcd.write(0xFF);
i++;
} else if (i < 32) {
lcd.print(" ");
i++;
}
}
lcd.clear();
lcd.print("Connected");
lcd.setCursor(0, 1);
lcd.print(WiFi.localIP());
} }
void loop() { void loop() {
; ;
} }