基于stc15f2k60s2芯片单片机编程(输密码)

这篇博客详细介绍了如何使用STC15F2K60S2单片机进行密码输入的编程操作。代码包括main.c和juzhen.h文件,通过修正代码实现特定的数码管显示效果,例如上电时数码管显示一个横杠。内容涉及单片机编程技巧和数码管控制技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述main.c

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

extern unsigned char cun[];
unsigned char display[]={
   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
unsigned char shuzu[]={
   0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf};
extern unsigned char key;
extern unsigned char a;

void xianshi();
void Timer0Init();


void main()
{
   

Timer0Init();EA=1;ET0=1;
	P2=0XA0;P0=0X00;


while(1)
	{
   
	anjian();
	xianshi();
	
	}



}

void xianshi()
{
   
	if(a==8)
	{
   
		display[0]=shuzu[cun[7]];//                     a为按键按下次数,每按一次,给数码管赋值一次
		display[1]=shuzu[cun[6]];
		display[2]=shuzu[cun[5]];
		display[3]=shuzu[cun[4]];
		display[4]=shuzu[cun[3]];
		display[5]=shuzu[cun[2]];
		display[6]=shuzu[cun[1]];
		display[7]=shuzu[cun[0]];
	}
		if(a==7)
	{
   
		display[0]=0xbf;//                        a为按键按下次数,每按一次,给数码管赋值一次
		display[1]=shuzu[cun[6]];
		display[2]=shuzu[cun[5]];
		display[3]=shuzu[cun[4]];
		display[4]=shuzu[cun[3]];
		display[5]=shuzu[cun[2]];
		display[6]<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值