LoginSignup
0
0

More than 1 year has passed since last update.

wemosでlcdkeypad その5

Posted at

概要

wemos d1で、lcdkeypadを使ってみた。
練習問題、やってみた。

練習問題

時計を表示せよ。

サンプルコード

#include <LiquidCrystal.h>
#include <ESP8266WiFi.h>
#include <TZ.h>

const char * ssid = "****";
const char * password = "****";

LiquidCrystal lcd(0, 2, 4, 14, 12, 13);
void setup() {
	lcd.begin(16, 2);
	lcd.setCursor(0, 0);
	lcd.print("Hello World!");
	WiFi.begin(ssid, password);
	Serial.println("");
	while (WiFi.status() != WL_CONNECTED)
	{
		delay(500);
		Serial.print(".");
	}
	Serial.println("");
	Serial.print("Connected to ");
	Serial.println(ssid);
	Serial.print("IP address: ");
	Serial.println(WiFi.localIP());
	lcd.setCursor(0, 0);
	lcd.print("IP address: ");
	lcd.setCursor(0, 1);
	lcd.print(WiFi.localIP());
	configTime(TZ_Asia_Tokyo, "pool.ntp.org");
}
void loop() {
	time_t t = time(NULL);
	struct tm * tm = gmtime(&t);
	time_t t2 = mktime(tm) + 3600;
	struct tm * tm2 = localtime(&t2);
	Serial.print("asctime: ");
	Serial.println(asctime(tm2));
	lcd.setCursor(0, 0);
	lcd.print(asctime(tm2));
	delay(1000);
}




以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0