师傅所教知识制作了一个LCD12864的屏幕显示,字模自己软件下载的,俺们新手,写的粗糙
期末项目为时钟的显示和设定,内含闹钟
PU原理图
按键:PA0:暂停时钟
在暂停时钟后再按一次PA0则开始选择改变分钟(反白),继续按下PA0开始设置时钟的改变(反白)
PA1与PA2连用检测按键:数字的增加
PB0:数据的减少
PB1与PB2连用检测按键:确认改变
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
另外,我现在另添加的闹钟的设置,可在运行程序后设置闹钟,闹钟的设定没上传,原理类似
缺点: 1. 日期判定没有做完,只是进行了简单的判断,没有大月小月的判断,闰年这类的 2. 时钟的修改的增加判断23的时候没用反白和清屏
修改代码如下
//减少
if(Key_Scan(KEY2_GPIO_PORT,KEYB0_GPIO_PIN) == KEY_ON)
{
if(a == 1)
{
a = a+ 22;
LCD12864_SeleScreen(LCD12864_Left);
LCD12864_Dsp_number1_1(38,3,a);
}else
{
a = a - 1;
LCD12864_SeleScreen(LCD12864_Left);
LCD12864_Dsp_12x24_Num(38,3,0xff);
LCD12864_Dsp_number1_1(38,3,a);
}
}
//增加
if(Key_Scan(KEY1_GPIO_PORT,KEYA1_GPIO_PIN) == KEY_ON)
{
if(a == 23)
{
ri = ri + 1;
a= a * 0+1;
LCD12864_SeleScreen(LCD12864_Right);
LCD12864_Dsp_number_2(35,0, ri);
LCD12864_SeleScreen(LCD12864_Left);
LCD12864_Dsp_12x24_Num(38,3,0xff);
LCD12864_Dsp_number1_1(38,3,a);
}else
{
a = a + 1;
LCD12864_SeleScreen(LCD12864_Left);
LCD12864_Dsp_12x24_Num(38,3,0xff);
LCD12864_Dsp_number1_1(38,3,a);
}
}
单片机源程序如下:
- #include "stm32f10x.h" // 相当于51单片机中的 #include <reg51.h>
- #include ".\LED\bsp_LED.h"
- #include ".\KEY\bsp_key.h"
- #include "delay.h"
- #include "sys.h"
- #include ".\beep\beep.h"
- int main(void)
- {
- Init();
- led_init();
- key_init();
- BEEP_Init();//喇叭初始化
- play_successful();
-
- LCD12864_Dsp_zhonghe(2020,11,31,7,23,55
- ,1,2); //年份,月份,日期,星期,小时,分钟,
- //闹钟
- // LCD12684_Dsp_perture();
- // delay10ms(100);
- // clearScreen(LCD12864_Full);
- // LCD12864_Write_Command(0x3F);
- // LCD12864_Dsp_time(2020);//年份
- // LCD12864_Dsp_time2(11,25);//月份,日期
- // LCD12864_Dsp_time1(5); //星期
- // LCD12864_Dsp_shijian(24,58);//小时,分钟
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
-
- // while(1)
- // {
- //// PlayMusic(); //播放生日快乐
- // // play_music();
- // play_music();
- // }
- //
- }
复制代码 另外我还录制了视频 文件太大 发不上来
所有资料51hei提供下载:
程序+仿真.7z
(1.59 MB, 下载次数: 406)
|