STC89C516RD+的C语言

来源:百度知道 编辑:UC知道 时间:2024/09/23 03:26:59
请问单片机的C语言应该怎么写,我已经下载装了KEIL软件了,汇编的能通过编译并且能下载了,但是C语言的我不知道怎么写,请高手指点,给我举个例子,包括头文件的使用

比如有8个灯,让它一个个轮流的亮,我的是低电平点亮的,谢谢!!!

#include <reg51.h>

void Delay1ms(unsigned int count)//延时
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++);
}

main()
{
unsigned char LEDIndex = 0;
bit LEDDirection = 1;

while(1)
{
if(LEDDirection)
P1 = ~(0x01<<LEDIndex);
else
P1 = ~(0x80>>LEDIndex);
if(LEDIndex==7)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%8;
Delay1ms(1000);
}
}

P1口流水灯。

你打电话给宏晶的姚工吧.