微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > AVR单片机学习程序(音乐合成)

AVR单片机学习程序(音乐合成)

时间:10-23 来源:互联网 点击:

//AVR单片机学习程序
//名称:音乐合成
//硬件:AVR-ATMEGA16实验板
//修改日志:
#includeiom16v.h>
#include macros.h>

//-------------位拉高--------------------------------------------
#define ADC0_H PORTA|=BIT(PA0)
#define ADC1_H PORTA|=BIT(PA1)
#define LEDLK_H PORTA|=BIT(PA2) //流水灯选通
#define SEGLK_H PORTA|=BIT(PA3) //数码管段码选通
#define BITLK_H PORTA|=BIT(PA4) //数码管位选通
//#define 18B20_H PORTA|=BIT(PA5)
#define BEEP_H PORTA|=BIT(PA6) //蜂鸣器
#define CUSB_H PORTA|=BIT(PA7)
//#define ~YY PORTD|=BIT(PD7)
//-------------位拉低--------------------------------------------
#define ADC0_L PORTA=~BIT(PA0)
#define ADC1_L PORTA=~BIT(PA1)
#define LEDLK_L PORTA=~BIT(PA2)
#define SEGLK_L PORTA=~BIT(PA3)
#define BITLK_L PORTA=~BIT(PA4)
//#define 18B20_L PORTA=~BIT(PA5)
#define BEEP_L PORTA=~BIT(PA6)
#define CUSB_L PORTA=~BIT(PA7)
//#define YY PORTD=~BIT(PD7)

#define NOP() asm(nop)

#define uchar unsigned char
#define uint unsigned int

uint a,x;

//====================音乐数据表=============================================

__flash uchar yin[]={
//《我们从这里起飞》
119,119,106,94,119,106,119,106,119,159,
119,119,106,94,89,94,106,142,126,119,94,106,94,89,79,71,79,94,106,
126,119,106,94,142,159,119,94,71,79,94,119,106,159,106,119,
119,119,89,79,71,79,71,59,71,89,71,79,79,79,94,71,79,94,119,
106,159,126,119,106,119,119,89,79,71,59,71,89,71,79,94,
59,79,94,71,79,94,119,106,159,94,106,119,
119,119,106,94,119,106,119,106,119,159,
119,119,106,94,89,94,106,142,126,119,94,106,94,89,79,71,79,94,106,
126,119,106,94,142,159,119,94,71,79,94,119,106,159,106,119,
//119,119,106,94,89,94,89,71,89,106,89,94,94,94,119,94,94,119,119,
//126,159,126,119,106,119,119,106,94,89,71,89,106,89,94,119,
//79,94,119,94,94,119,119,126,159,142,126,119,
119,119,89,79,71,79,71,59,71,89,71,79,79,79,94,71,79,94,119,
106,159,126,119,106,119,119,89,79,71,59,71,89,71,79,94,
59,79,94,71,79,94,119,106,159,94,106,119,
59,79,94,71,79,89,94,79,79,71,63,59,0,
//《你怎么说》
60,60,53,59,71,79,95,80,71,59,80,80,71,59,
53,53,59,53,47,0,39,47,53,47,47,79,71,
59,47,53,0,79,39,47,53,79,47,53,59,
59,53,47,47,39,47,53,59,71,79,59,59,53,47,94,79,94,106,94,
79,79,71,59,59,59,53,47,39,47,39,47,39,47,53,
59,53,53,59,53,47,47,53,59,53,47,39,0,79,39,47,
53,79,47,53,59,
60,60,53,59,71,79,95,80,71,59,80,80,71,59,
53,53,59,53,47,0,39,47,53,47,47,79,71,
59,47,53,0,79,39,47,53,79,47,53,59,
59,53,47,47,39,47,53,59,71,79,59,59,53,47,94,79,94,106,94,
79,79,71,59,59,59,53,47,39,47,39,47,39,47,53,
59,53,53,59,53,47,47,53,59,53,47,39,0,79,39,47,
53,79,47,53,59,
0,
//《八月桂花香》
59,71,79,71,59,79,71,59,71,79,71,59,79,
79,71,59,53,71,79,94,79,106,94,79,119,
79,71,59,79,94,106,119,106,79,71,59,79,94,106,119,106,
79,71,59,53,71,79,94,79,106,94,79,119,
79,71,59,53,71,79,94,47,59,53,47,59,0,
//《阿里山的姑娘》
94,79,94,106,94,79,71,79,94,106,94,79,94,94,106,106,
142,119,106,119,142,159,142,71,71,71,79,79,94,94,94,106,106,94,119,
142,142,106,106,106,94,79,94,94,106,94,106,119,119,106,119,142,159,142,142,
119,142,142,159,106,94,106,119,106,94,79,94,106,94,106,142,119,106,119,142,
159,142,71,71,71,79,79,94,94,106,94,106,94,119,142,142,106,106,106,94,
79,94,94,106,94,106,119,119,106,119,142,159,142,94,106,94,79,71,79,94,
106,94,79,94,106,142,119,106,119,142,159,142,71,71,71,79,79,94,94,106,
94,106,94,119,142,142,106,106,94,79,94,79,106,94,79,71,0,
71,71,71,71,71,59,53,59,71,79,94,71,79,59,71,79,106,94,79,79,106,94,106,142,
94,106,94,79,106,94,142,119,94,106,119,142,142,142,
94,106,94,79,71,79,94,
106,94,79,94,106,142,119,106,119,142,159,142,71,71,71,79,79,94,94,106,
94,106,94,119,142,142,106,106,94,79,94,79,106,94,79,71,0,
71,71,71,71,71,59,53,59,71,79,94,71,79,59,71,79,106,94,79,79,106,94,106,142,
94,106,94,79,106,94,142,119,94,106,119,142,142,142,
94,106,94,79,71,79,94,

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top