基于stc15f2k60s2芯片单片机编程(可调时钟)

Ds1302可调时钟,按下S7调节时分秒,按下S6加1,按下S5减1

mian.c

#include <stc15f2k60s2.h>
#include <intrins.h>
#include "ds1302.h"

void Timer0Init(void);
void xianshi();
void Delay10ms();
void anjian();


unsigned char display[]={
   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
unsigned char code shuzu[]={
   0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char wei;


sbit s7=P3^0;
sbit s6=P3^1;
sbit s5=P3^2;


void main()
{
   

	Timer0Init();EA=1;ET0=1;
	P2=(P2&0X1F)|0XA0;
	P0=0X00;
	P2&=0X1F;
	
	P2=(P2&0X1F)|0X80;
	P0=0XFF;
	P2&=0X1F;	
	

	write_ds();
	while(1)
	{
   

		anjian();
		xianshi();




	}



}

void xianshi()
{
   
	if(wei==0)
	{
   
		read_ds();
		display[0]=shuzu[time[2]/16];
		display[1]=shuzu[time[2]%16];
	//	display[2]=shuzu[3];
		display[3]=shuzu[time[1]/16];
		display[4]=shuzu[time[1]%16];
	//	display[5]=shuzu[6];
		display[6]=shuzu[time[0]/16];
		display[7]=shuzu[time[0]%16];
		
//		if((time[0]%16)%2==0)
//		{
   
//			display[2]=display[5]=0xbf;
  • 3
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值