新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > LPC2103学习板-蜂鸣器练习程序

LPC2103学习板-蜂鸣器练习程序

作者: 时间:2016-11-18 来源:网络 收藏

本文引用地址:https://www.eepw.com.cn/article/201611/316024.htm

/**************ARM7(LPC2103)练习程序**************************/
/************************************************************************/
/*****File Function : 蜂鸣器测试 *****/
/*****Program Author : ClimberWin *****/
/*****MCU : LPC2103F 外部11.0592M晶振 *****/
/*****Compile Date : 2011/04/01 *****/
/*****Edition Info : V1.0*****/
/*****************************************************************/
//编译环境 KEIL for ARM
//蜂鸣器 接口 P0.21

#include
#include
#define uint unsigned int
#define uchar unsigned char

#define speak (1<<21) //定义按键1的引脚

void delayms(unsigned int count);//延时程序
void speakertest(void);//蜂鸣器测试程序
/*************延时程序***************/

void delayms(unsigned int count)
{
unsigned int i,j;
for(i=0;ifor(j=0;j<5000;j++);
}


/***************************************************/
void speakertest(void)//蜂鸣器测试程序
{
uchar i;
for(i=0;i<100;i++)
{
IO0CLR=0x00200000;
delayms(1);
IO0SET=0x00200000;
delayms(1);
}
}
/*****************************************/


/////////////主程序///////////////////
void main(void)
{
uchar i;
IO0DIR=0x0027fc00; //配置P0.8-P1.5为输出 P21输出

speakertest();
while(1);

}



关键词: LPC2103蜂鸣

评论


技术专区

关闭