/*--------------------------------------------------------------------------1--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------本程序所引用库--------------------------------------------------------------------*/
/*
本程序需要搜索安装如下库(括号里是库的作者):
- LiquidCrystal I2C ( by Frank de Brabander )
*/
#include <Wire.h> // 用于控制I2C通信协议,允许控制其他I2C协议的设备
#include <LiquidCrystal_I2C.h> // 允许通过I2C总线与LCD显示屏进行通信和控制
/*--------------------------------------------------------------------------2--------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------变量声明-----------------------------------------------------------------------*/
/******************************常量声明******************************/
#define DELAY_TIME 8
const char cName[3][6][8] = {
{//张
{ 0x00, 0x1F, 0x01, 0x01, 0x01, 0x0F, 0x08, 0x08 },
{ 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x1F },
{ 0x00, 0x04, 0x04, 0x08, 0x10, 0x00, 0x00, 0x1F },
{ 0x08, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x0A, 0x04 },
{ 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 0x06, 0x04 },
{ 0x00, 0x10, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00 }
},
{//文
{0x00,0x00,0x00,0x1F,0x02,0x02,0x01,0x01},
{0x08,0x04,0x04,0x1F,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x1F,0x08,0x08,0x10,0x10},
{0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x18},
{0x11,0x0A,0x04,0x0A,0x11,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x10,0x0C,0x03}
},
{//君
{0x00,0x07,0x00,0x00,0x1F,0x00,0x00,0x07},
{0x00,0x1F,0x10,0x10,0x1F,0x10,0x10,0x1F},
{0x00,0x1C,0x04,0x04,0x1F,0x04,0x04,0x1C},
{0x01,0x01,0x03,0x03,0x05,0x09,0x11,0x01},
{0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00},
{0x00,0x00,0x1C,0x04,0x04,0x04,0x1C,0x04}
} };
const char cClass[2][6][8] = {
{//电
{0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x07},
{0x04,0x04,0x04,0x1F,0x04,0x04,0x04,0x1F},
{0x00,0x00,0x00,0x1C,0x04,0x04,0x04,0x1C},
{0x04,0x04,0x04,0x07,0x04,0x00,0x00,0x00},
{0x04,0x04,0x04,0x1F,0x04,0x04,0x04,0x03},
{0x04,0x04,0x04,0x1C,0x05,0x01,0x01,0x1F}
},
{//信
{0x01,0x01,0x01,0x02,0x02,0x06,0x06,0x0A},
{0x01,0x00,0x0F,0x00,0x00,0x07,0x00,0x00},
{0x00,0x10,0x1F,0x00,0x00,0x1E,0x00,0x00},
{0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02},
{0x07,0x00,0x00,0x07,0x04,0x04,0x07,0x04},
{0x1E,0x00,0x00,0x1E,0x02,0x02,0x1E,0x02}
}
};
const char cHome[6][6][8] = {
{//山
{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04},
{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04},
{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04},
{0x04,0x04,0x04,0x04,0x04,0x07,0x00,0x00},
{0x04,0x04,0x04,0x04,0x04,0x1F,0x00,0x00},
{0x04,0x04,0x04,0x04,0x04,0x1C,0x04,0x00}
},
{//东
{0x00,0x00,0x00,0x0F,0x00,0x01,0x02,0x04},
{0x08,0x08,0x08,0x1F,0x10,0x04,0x04,0x04},
{0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00},
{0x07,0x00,0x01,0x02,0x04,0x08,0x00,0x00},
{0x1F,0x04,0x04,0x04,0x04,0x04,0x14,0x08},
{0x1C,0x00,0x10,0x08,0x04,0x02,0x00,0x00}
},
{//菏
{0x00,0x00,0x1F,0x00,0x04,0x02,0x02,0x10},
{0x11,0x11,0x1F,0x11,0x00,0x1F,0x00,0x00},
{0x00,0x00,0x1F,0x00,0x00,0x1F,0x04,0x04},
{0x09,0x09,0x02,0x1C,0x04,0x04,0x04,0x00},
{0x0F,0x09,0x09,0x0F,0x09,0x00,0x00,0x00},
{0x04,0x04,0x04,0x04,0x04,0x04,0x14,0x08}
},
{//泽
{0x00,0x04,0x02,0x02,0x10,0x08,0x08,0x02},
{0x00,0x1F,0x08,0x04,0x02,0x01,0x06,0x19},
{0x00,0x1C,0x04,0x08,0x10,0x00,0x18,0x07},
{0x02,0x04,0x1C,0x04,0x04,0x04,0x04,0x00},
{0x01,0x0F,0x01,0x01,0x1F,0x01,0x01,0x01},
{0x00,0x1C,0x00,0x00,0x1E,0x00,0x00,0x00}
},
{
{0x00,0xf,0x9,0x1,0xf,0x02,0x02,0x4},
{0x00,0x1e,0x2,0x00,0x1e,0x00,0x10,0x10},
{0x00,0x1f,0x11,0x12,0x12,0x14,0x12,0x12},
{0xf,0x0,0x0,0x0,0x1f,0x8,0x00,0x00},
{0x1e,0x10,0x10,0x1e,0x10,0x10,0x10,0x10},
{0x11,0x11,0x11,0x1a,0x14,0x10,0x10,0x10},
},
{
{0x04,0x04,0x04,0x04,0x04,0x1f,0x04,0x04},
{0x00,0x00,0x00,0x1f,0x10,0x10,0x10,0x1e},
{0x14,0x12,0x10,0x1f,0x10,0x10,0x12,0x12},
{0x04,0x04,0x04,0x07,0x11,0x09,0x01,0x02},
{0x12,0x12,0x12,0x12,0x1a,0x04,0x01,0x02},
{0x12,0x14,0x14,0x08,0x09,0x15,0x3,0x01},
}
};
long Time;
int page = 0;
/******************************引脚声明******************************/
// 无
/******************************变量声明******************************/
// unsigned long LCD_Clear_Time = 0; // 记录上一次刷新时间
/******************************对象声明******************************/
LiquidCrystal_I2C lcd(0x27, 16, 2); // IIC地址,每行几个,共几行
/*--------------------------------------------------------------------------3--------------------------------------------------------------------------*/
/*-------------------------------------------------------------------setup()程序初始化------------------------------------------------------------------*/
void setup() {
/******************************启动串口通讯******************************/
Serial.begin(9600); // 初始化串口通信,并设置波特率为9600
/*******************************初始化CLD********************************/
lcd.init(); // 初始化LCD
lcd.backlight(); // 开启背光
Time = millis();
}
/*--------------------------------------------------------------------------4--------------------------------------------------------------------------*/
/*-------------------------------------------------------------------loop()基础循环体-------------------------------------------------------------------*/
void loop() {
showName();
showClass();
showId();
showHome();
showHome2();
}
void name1()
{
lcd.clear();
lcd.createChar(0, cName[0][0]);
lcd.createChar(1, cName[0][1]);
lcd.createChar(2, cName[0][2]);
lcd.createChar(3, cName[0][3]);
lcd.createChar(4, cName[0][4]);
lcd.createChar(5, cName[0][5]);
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.setCursor(1, 0);
lcd.write(byte(1));
lcd.setCursor(2, 0);
lcd.write(byte(2));
lcd.setCursor(0, 1);
lcd.write(byte(3));
lcd.setCursor(1, 1);
lcd.write(byte(4));
lcd.setCursor(2, 1);
lcd.write(byte(5));
}
void name2()
{
lcd.clear();
lcd.createChar(0, cName[1][0]);
lcd.createChar(1, cName[1][1]);
lcd.createChar(2, cName[1][2]);
lcd.createChar(3, cName[1][3]);
lcd.createChar(4, cName[1][4]);
lcd.createChar(5, cName[1][5]);
lcd.setCursor(3, 0);
lcd.write(byte(0));
lcd.setCursor(4, 0);
lcd.write(byte(1));
lcd.setCursor(5, 0);
lcd.write(byte(2));
lcd.setCursor(3, 1);
lcd.write(byte(3));
lcd.setCursor(4, 1);
lcd.write(byte(4));
lcd.setCursor(5, 1);
lcd.write(byte(5));
}
void name3()
{
lcd.clear();
lcd.createChar(0, cName[2][0]);
lcd.createChar(1, cName[2][1]);
lcd.createChar(2, cName[2][2]);
lcd.createChar(3, cName[2][3]);
lcd.createChar(4, cName[2][4]);
lcd.createChar(5, cName[2][5]);
lcd.setCursor(6, 0);
lcd.write(byte(0));
lcd.setCursor(7, 0);
lcd.write(byte(1));
lcd.setCursor(8, 0);
lcd.write(byte(2));
lcd.setCursor(6, 1);
lcd.write(byte(3));
lcd.setCursor(7, 1);
lcd.write(byte(4));
lcd.setCursor(8, 1);
lcd.write(byte(5));
}
void showName()
{
unsigned long currentMillis = millis();
unsigned long previousMillis = millis();
while (1) {
currentMillis = millis();
if (currentMillis - previousMillis >= 1000 * 3) {
break;
}
name1();
delay(DELAY_TIME);
name2();
delay(DELAY_TIME);
name3();
delay(DELAY_TIME);
}
}
void class1()
{
lcd.clear();
lcd.createChar(0, cClass[0][0]);
lcd.createChar(1, cClass[0][1]);
lcd.createChar(2, cClass[0][2]);
lcd.createChar(3, cClass[0][3]);
lcd.createChar(4, cClass[0][4]);
lcd.createChar(5, cClass[0][5]);
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.setCursor(1, 0);
lcd.write(byte(1));
lcd.setCursor(2, 0);
lcd.write(byte(2));
lcd.setCursor(0, 1);
lcd.write(byte(3));
lcd.setCursor(1, 1);
lcd.write(byte(4));
lcd.setCursor(2, 1);
lcd.write(byte(5));
}
void class2()
{
lcd.clear();
lcd.createChar(0, cClass[1][0]);
lcd.createChar(1, cClass[1][1]);
lcd.createChar(2, cClass[1][2]);
lcd.createChar(3, cClass[1][3]);
lcd.createChar(4, cClass[1][4]);
lcd.createChar(5, cClass[1][5]);
lcd.setCursor(3, 0);
lcd.write(byte(0));
lcd.setCursor(4, 0);
lcd.write(byte(1));
lcd.setCursor(5, 0);
lcd.write(byte(2));
lcd.setCursor(3, 1);
lcd.write(byte(3));
lcd.setCursor(4, 1);
lcd.write(byte(4));
lcd.setCursor(5, 1);
lcd.write(byte(5));
}
void showClass()
{
unsigned long currentMillis = millis();
unsigned long previousMillis = millis();
while (1) {
currentMillis = millis();
if (currentMillis - previousMillis >= 1000 * 3) {
break;
}
class1();
delay(DELAY_TIME);
class2();
delay(DELAY_TIME);
lcd.setCursor(6, 0);
lcd.print("2232");
delay(DELAY_TIME);
}
}
void showId()
{
unsigned long currentMillis = millis();
unsigned long previousMillis = millis();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("202208301037");
while (1) {
currentMillis = millis();
if (currentMillis - previousMillis >= 1000 * 3) {
break;
}
delay(DELAY_TIME);
}
}
void home1()
{
lcd.clear();
lcd.createChar(0, cHome[0][0]);
lcd.createChar(1, cHome[0][1]);
lcd.createChar(2, cHome[0][2]);
lcd.createChar(3, cHome[0][3]);
lcd.createChar(4, cHome[0][4]);
lcd.createChar(5, cHome[0][5]);
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.setCursor(1, 0);
lcd.write(byte(1));
lcd.setCursor(2, 0);
lcd.write(byte(2));
lcd.setCursor(0, 1);
lcd.write(byte(3));
lcd.setCursor(1, 1);
lcd.write(byte(4));
lcd.setCursor(2, 1);
lcd.write(byte(5));
}
void home2()
{
lcd.clear();
lcd.createChar(0, cHome[1][0]);
lcd.createChar(1, cHome[1][1]);
lcd.createChar(2, cHome[1][2]);
lcd.createChar(3, cHome[1][3]);
lcd.createChar(4, cHome[1][4]);
lcd.createChar(5, cHome[1][5]);
lcd.setCursor(3, 0);
lcd.write(byte(0));
lcd.setCursor(4, 0);
lcd.write(byte(1));
lcd.setCursor(5, 0);
lcd.write(byte(2));
lcd.setCursor(3, 1);
lcd.write(byte(3));
lcd.setCursor(4, 1);
lcd.write(byte(4));
lcd.setCursor(5, 1);
lcd.write(byte(5));
}
void home3()
{
lcd.clear();
lcd.createChar(0, cHome[2][0]);
lcd.createChar(1, cHome[2][1]);
lcd.createChar(2, cHome[2][2]);
lcd.createChar(3, cHome[2][3]);
lcd.createChar(4, cHome[2][4]);
lcd.createChar(5, cHome[2][5]);
lcd.setCursor(6, 0);
lcd.write(byte(0));
lcd.setCursor(7, 0);
lcd.write(byte(1));
lcd.setCursor(8, 0);
lcd.write(byte(2));
lcd.setCursor(6, 1);
lcd.write(byte(3));
lcd.setCursor(7, 1);
lcd.write(byte(4));
lcd.setCursor(8, 1);
lcd.write(byte(5));
}
void home4()
{
lcd.clear();
lcd.createChar(0, cHome[3][0]);
lcd.createChar(1, cHome[3][1]);
lcd.createChar(2, cHome[3][2]);
lcd.createChar(3, cHome[3][3]);
lcd.createChar(4, cHome[3][4]);
lcd.createChar(5, cHome[3][5]);
lcd.setCursor(9, 0);
lcd.write(byte(0));
lcd.setCursor(10, 0);
lcd.write(byte(1));
lcd.setCursor(11, 0);
lcd.write(byte(2));
lcd.setCursor(9, 1);
lcd.write(byte(3));
lcd.setCursor(10, 1);
lcd.write(byte(4));
lcd.setCursor(11, 1);
lcd.write(byte(5));
}
void home5()
{
lcd.clear();
lcd.createChar(0, cHome[4][0]);
lcd.createChar(1, cHome[4][1]);
lcd.createChar(2, cHome[4][2]);
lcd.createChar(3, cHome[4][3]);
lcd.createChar(4, cHome[4][4]);
lcd.createChar(5, cHome[4][5]);
lcd.setCursor(12, 0);
lcd.write(byte(0));
lcd.setCursor(13, 0);
lcd.write(byte(1));
lcd.setCursor(14, 0);
lcd.write(byte(2));
lcd.setCursor(12, 1);
lcd.write(byte(3));
lcd.setCursor(13, 1);
lcd.write(byte(4));
lcd.setCursor(14, 1);
lcd.write(byte(5));
}
void showHome()
{
unsigned long currentMillis = millis();
unsigned long previousMillis = millis();
while (1) {
currentMillis = millis();
if (currentMillis - previousMillis >= 1000 * 3) {
home5();
break;
}
home1();
delay(DELAY_TIME);
home2();
delay(DELAY_TIME);
home3();
delay(DELAY_TIME);
home4();
delay(DELAY_TIME);
home5();
delay(DELAY_TIME);
}
}
void home6()
{
lcd.clear();
lcd.createChar(0, cHome[5][0]);
lcd.createChar(1, cHome[5][1]);
lcd.createChar(2, cHome[5][2]);
lcd.createChar(3, cHome[5][3]);
lcd.createChar(4, cHome[5][4]);
lcd.createChar(5, cHome[5][5]);
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.setCursor(1, 0);
lcd.write(byte(1));
lcd.setCursor(2, 0);
lcd.write(byte(2));
lcd.setCursor(0, 1);
lcd.write(byte(3));
lcd.setCursor(1, 1);
lcd.write(byte(4));
lcd.setCursor(2, 1);
lcd.write(byte(5));
}
void showHome2()
{
unsigned long currentMillis = millis();
unsigned long previousMillis = millis();
while (1) {
currentMillis = millis();
if (currentMillis - previousMillis >= 1000 * 3) {
break;
}
home6();
}
}