为了保存住假期里学习过的单片机,尽量做到一个星期模仿一个实例,也是进一步学习Proteus。
今天编写的是LED间隔闪光,时间为1S,仿真软件Proteus。
/* Main.c file generated by New Project wizard
*
* Created: 周六 11月 25 2017
* Processor: 80C52
* Compiler: Keil for 8051
* Author: Chenchong
*/
#include <reg51.h>
#include <stdio.h>
#define uchar unsigned char
#define uint unsigned int
sbit LED=P1^0;
void DelayXms(uint x)
{
uchar i;
while(x--)
{
for(i=0;i<120;i++);
}
}
void main(void)
{
// Write your code here
while (1)
{
LED=~LED;
DelayXms(1000);
}
;
}