• 方案介绍
  • 附件下载
  • 相关推荐
申请入驻 产业图谱

基于51单片机的收银机【数码管,矩阵键盘】(仿真)

4小时前
70
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

有需要资料的可了解一下.docx

共1个文件

#include "74hc595.h"
//595发送函数
void Hc595SendByte(uchar i,uchar j)
{
	uchar a,dat1;
	dat1=i;
	SRRCLK = 1;
	RRCLK = 1;

	for(a=0;a<8;a++)		//发送8位数
	{
		if(dat1 & 0x80)
			SER =1;	//从最高位开始发送
		else
			SER=0;
		dat1 <<= 1;

		SRRCLK = 0;			//发送时序
		_nop_();
		_nop_();
		SRRCLK = 1;	
	}
	dat1=j;
	SRRCLK = 1;
	RRCLK = 1;
	for(a=0;a<8;a++)		//发送8位数
	{
		if(dat1 & 0x80)
			SER =1;	//从最高位开始发送
		else
			SER=0;
		dat1 <<= 1;

		SRRCLK = 0;			//发送时序
		_nop_();
		_nop_();
		SRRCLK = 1;	
	}
	RRCLK = 0;
	_nop_();
	_nop_();
	RRCLK = 1;
}
 led2=P1^1;
sbit led3=P1^2;
sbit k1=P3^6;
//数码管编码
uchar code smgduan0[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};//显示0~9,无小数点
uchar code smgduan1[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};//显示0~9,有小数点
uchar mode=0;//系统变量
uchar xian[]={0,0,0,0,0,0,0,0};//显存
uchar dian=0,flag=0;//小数点标志
uchar key=0;
float aa=0,bb=0,cc=0;


//


sbit sound=P3^7;						//蜂鸣器位置
unsigned int duty;   				//定时初值变量
unsigned char state_INT=0;  //中断状态变量
void Init_Timer0();//中断
void Music_Player();

void Delayms(unsigned int n)
{
	unsigned int i,j;
	for(i=0;i<n;i++)
		for(j=0;j<640;j++);
}

void Init_Timer0()
{
	TMOD=0x00;  			//13位非自动
	TH0=(8192-duty)/32;
	TL0=(8192-duty)%32;
	
	TF0=0;
	ET0=1;
	
	IT0=1;
	EX0=1;  					//设置中断
	
	EA=1;
}

void Serve_Timer0() interrupt 1
{
	TH0=(8192-duty)/32;
	TL0=(8192-duty)%32;
	
	sound=!sound;
}

void Serve_INT0() interrupt 0      //电子琴调试中断代码
{
	if(INT0==0)
	{
		state_INT++;	
		if(state_INT>=3)
			state_INT=0;
	}
	while(INT0==0);      //等待开关松开
}

//

/*****************音阶及对应频率**********************/
#define l1 262    
#define l2 286    
#define l3 311    
#define l4 349    
#define l5 392    
#define l6 440    
#define l7 494    
//中音
#define z1 523     
#define z2 587     
#define z3 659     
#define z4 698     
#define z5 784    
#define z6 880     
#define z7 987          
//高音
#define h1 1046    
#define h2 1174    
#define h3 1318    
#define h4 1396    
#define h5 1567   
#define h6 1760    
#define h7 1975    

#define C 262    
#define D 294    
#define E 330    
#define F 349    
#define G 392    
#define A 440    
#define B 494    
//中音
#define c 523     
#define d 587     
#define e 659     
#define f 698     
#define g 784    
#define a 880     
#define b 987          
//高音
//#define h1 1046    
//#define h2 1174    
//#define h3 1318    
//#define h4 1396    
//#define h5 1567   
//#define h6 1760    
//#define h7 1975    
/**********************************************************/




///


/**********************我和我的祖国*J=l50**************************************/
unsigned int code music[]=
{ 
	z5,2, z6,2, z5,2, z4,2, z3,2, z2,2,/**/ 
	z1,6, l5,6, /**/
	z1,2, z3,2, h1,2, z7,2, z6,4, z3,1,/**/
	z5,6, z5,6, /**/
	z6,2, z7,2, z6,2, z5,2, z4,2, z3,2, /**/
	z2,6, l6,6,/**/
	l7,2, l6,2, l5,2, z5,2, z1,4, z2,1,/**/
	z3,6, z3,6, /**/
	z5,2, z6,2, z5,2, z4,2, z3,2, z2,2, /**/
	z1,6, l5,6,/**/
	z1,2, z3,2, h1,2, z7,2, h2,4, h1,1, /**/
	z6,6, z6,6,/**/
	h1,2, z7,2, z6,2, z5,6,/**/ 
	z6,2, z5,2, z4,2, z3,6,/**/
	l7,4, l6,2, l5,4, z2,2,/**/
	z1,6, z1,6,/**/
	h1,2, h2,2, h3,2, h2,2, h1,2, z6,2, /**/
	z7,2, z6,4, z3,1, z5,6, z5,6, /**/
	h1,2, h2,2, h3,2, h2,2, h1,2, z6,2,/**/
	z7,2, z5,4, z3,1, z6,6, z6,6, /**/
	z5,2, z4,2, z3,2, z2,6, /**/
	l7,2, l6,1, l6,1, l5,2, z3,6, /**/
	z4,6, z2,4, z1,2, /**/
	z1,6, z1,6, /**/
	h1,2, h2,2, h3,2, h2,2, h1,2, z6,2, /**/
	z7,2, z6,4, z3,1, z5,6, /**/
	h1,2, h2,2, h3,2, h2,2, h1,2, z6,2, /**/
	z7,2, z5,4, z3,1, z6,6, /**/
	z5,2, z4,2, z3,2, z2,6, /**/
	l7,2, l6,2, l5,2, z3,6,/**/ 
	z5,6, h2,4, h1,2, /**/
	h1,6,z1,12, /**/
	0xff }; 
/******************************************************************************/

/****************知否知否* J=52*************************************************/
unsigned int code music1[]=
{
	z1,2, z2,2,/**/
	z3,2, z2,1, z3,1,l6,4,z3,2, z2,1, z3,1, z2,3,/**/	
	l7,2, l5,10,l6,1,l5,1,/**/
	l6,2, l5,1, l6,1,z3,2,z3,5, z2,1, z1,1,/**/
	z2,2, z3,1, z3,5,/**/
	z1,2, z2,2, z3,2,z2,1,z3,1, l6,3, l6,1, z3,2, z2,1, z1,1, z5,2,/**/
	z3,8, z3,1, z5,1,/**/
	z6,2, z3,1, z2,1,z3,2,z1,2, z2,2, z1,2,/**/
	l7,2, l5,1, l6,5,	/**/
	z3,1, z6,1, z6,1,z5,1,z6,1, z3,2, z3,1, z7,1, z7,1, z6,1, z7,1, z3,3,/**/	
	h1,1, z7,1, z6,1,z5,1,z6,1, z5,1, z3,1, z2,1, z3,1, z5,2, z3,1, z3,4, z3,1,/**/
	l6,8, z3,2, l7,8,/**/
	l7,1, z1,1, z2,3,z2,1,z3,1, z4,1, z3,7,	/**/
	z3,1, z6,1, z6,1,z5,1,z6,1, z3,2, z3,1, z7,1, z7,1, z6,1, z7,1, z3,3,/**/ 	
	h1,1, z7,1, z6,1,z5,1,z6,1, z7,1, h1,1, h2,

资料借鉴于此纷传

  • 有需要资料的可了解一下.docx
    下载

相关推荐

方案定制

去合作
方案开发定制化,2000+方案商即时响应!