这是流水灯C语言编程,针对单片机的仿真,可以在Keil或是在C++中实现编程。
流水灯C语言编程
#include
#include
#define LED_PORT1 P1
#define LED_PORT2 P2
void time(unsigned int ucMS) ; void main(void)
{
unsigned char
while (1)
{
for(ucTimes=0;ucTimes<8;ucTimes++) { LED_PORT1=_cror_(0xfe,ucTimes);
time(DELAY_TIME); } LED_PORT1=0xff; ucTimes; #define DELAY_TIME 200 for(ucTimes=0;ucTimes<8;ucTimes++) { LED_PORT2=_cror_(0xfe,ucTimes); time(DELAY_TIME); } LED_PORT2=0xff; } } void delay_5us(void) { _nop_(); _nop_();
}
void delay_50us(void)
{
unsigned char i for(i=0;i<4; i++)
{ delay_5us(); } } void delay_100us (void) { ;