• 方案介紹
  • 附件下載
  • 相關(guān)推薦
申請入駐 產(chǎn)業(yè)圖譜

基于51單片機的收銀機【數(shù)碼管,矩陣鍵盤】(仿真)

01/19 08:45
638
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點資訊討論

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

共1個文件

#include "74hc595.h"
//595發(fā)送函數(shù)
void Hc595SendByte(uchar i,uchar j)
{
	uchar a,dat1;
	dat1=i;
	SRRCLK = 1;
	RRCLK = 1;

	for(a=0;a<8;a++)		//發(fā)送8位數(shù)
	{
		if(dat1 & 0x80)
			SER =1;	//從最高位開始發(fā)送
		else
			SER=0;
		dat1 <<= 1;

		SRRCLK = 0;			//發(fā)送時序
		_nop_();
		_nop_();
		SRRCLK = 1;	
	}
	dat1=j;
	SRRCLK = 1;
	RRCLK = 1;
	for(a=0;a<8;a++)		//發(fā)送8位數(shù)
	{
		if(dat1 & 0x80)
			SER =1;	//從最高位開始發(fā)送
		else
			SER=0;
		dat1 <<= 1;

		SRRCLK = 0;			//發(fā)送時序
		_nop_();
		_nop_();
		SRRCLK = 1;	
	}
	RRCLK = 0;
	_nop_();
	_nop_();
	RRCLK = 1;
}
 led2=P1^1;
sbit led3=P1^2;
sbit k1=P3^6;
//數(shù)碼管編碼
uchar code smgduan0[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};//顯示0~9,無小數(shù)點
uchar code smgduan1[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};//顯示0~9,有小數(shù)點
uchar mode=0;//系統(tǒng)變量
uchar xian[]={0,0,0,0,0,0,0,0};//顯存
uchar dian=0,flag=0;//小數(shù)點標志
uchar key=0;
float aa=0,bb=0,cc=0;


//


sbit sound=P3^7;						//蜂鳴器位置
unsigned int duty;   				//定時初值變量
unsigned char state_INT=0;  //中斷狀態(tài)變量
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;  					//設(shè)置中斷
	
	EA=1;
}

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

void Serve_INT0() interrupt 0      //電子琴調(diào)試中斷代碼
{
	if(INT0==0)
	{
		state_INT++;	
		if(state_INT>=3)
			state_INT=0;
	}
	while(INT0==0);      //等待開關(guān)松開
}

//

/*****************音階及對應(yīng)頻率**********************/
#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
    下載

相關(guān)推薦

方案定制

去合作
方案開發(fā)定制化,2000+方案商即時響應(yīng)!