当前位置:网站首页>Supplementary cases of single chip microcomputer -- two tigers

Supplementary cases of single chip microcomputer -- two tigers

2020-12-06 16:27:21 zhangrelay

take led Change to a horn , It's also very easy to program music and electronic organ functions , Single chip computer two tiger cases, many online information will not be listed , Just search :

here , give sdcc Under the plan , Example code of using horn pronunciation :

/*****************************************************************************
 *                     The header file                                    *
 *****************************************************************************/
#include "8052.h"    
__sbit __at (0xEC) P4_4;
// Port definition -- Function keys control LED The light is on and off 
#define LSA   P1_5  			
#define LSB   P1_6  			
#define LSC   P1_7 
#define LED0   P0_0 
#define LED1   P0_1 
#define LED2   P0_2 
#define LED3   P0_3 
#define KEY0   P3_2 
#define KEY1   P3_3 
#define KEY2   P3_4 
#define KEY3   P3_5 
unsigned char sound;
/*****************************************************************************
 *                              initialization                                    *
 *****************************************************************************/
void delay(unsigned int hz)	//
{
	while(hz--);
}

void sys_init(void)
{
	 LSA = 0;
	 LSB = 0;
	 LSC = 0;
	 sound=0; 
}
/*****************************************************************************
 *                              The main function                                    *
 *****************************************************************************/
void main(void)
{
    sys_init();
    while(1)
    {
        /* send per 0ms */
        delay(200);
        P4_4=1;
        delay(200);
        P4_4=0;
    }
}

 

版权声明
本文为[zhangrelay]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201206162656871p.html