LCD1602滚动显示切换播放暂停字符串
显示Public Places
显示No Smoking
播放
暂停
部分代码
char zifu1[] = "Public Places ";
char zifu2[] = "Class Now ";
char zifu3[] = "No admittance ";
char *zifu[] = { zifu1, zifu2, zifu3 };
char juti_L[3] = { 16, 16, 16 };
char zifu12[] = "No Smoking ";
char zifu22[] = "Quiet Please ";
char zifu32[] = "Staff Only ";
char *zifu22a[] = { zifu12, zifu22, zifu32 };
char juti_L2[3] = { 16, 16, 16 };
int main(void)
{
char key_v;
char time = 0;
char start_char_num = 0;
WDTCTL = WDTPW | WDTHOLD; /* Stop watchdog timer */
Clock_Init(); /* 系统时钟设置 */
key_init(); /*按键初始化 */
Port_init(); /* 显示器引脚初始化 */
LCD_init(); /* 显示器初始化 */
_EINT(); /* 开中断 */
display(0, 0); /* 显示哪一个字符 从哪开始显示 */
display_2(0, 0);
while (1)
{
key_v = KeySscan();
if (key_v != 0)
{
if (key_v == 1)
{
num++;
if (num == 3)
num = 0;
display(num, 0);
display_2(num, 0);
start_char_num = 0;
}
else if (key_v == 2)
{
start = 1;
}
else if (key_v == 3)
{
start = 0;
}
}
delay_ms(10);
if (start == 1)
{
time++;
if (time == 27)
{
time = 0; /* 时间控制 */
start_char_num++; //从哪里开始显示
if (start_char_num >= juti_L[num])
{
start_char_num = 0;
}
display(num, start_char_num); /* 显示哪一个字符 从哪开始显示 */
display_2(num, start_char_num); /* 显示哪一个字符 从哪开始显示 */
}
}
}
}
全部程序
https://docs.qq.com/sheet/DUEdqZ2lmbmR6UVdU?tab=BB08J2