Mình có đoạn code con 89c2051 viết bằng KeilcC như sau
#include <REG2051.H>
void waitasecond()
{
unsigned int x;
for(x=0;x<33000;x++);
}
void main()
{
unsigned char LED=128;
while(1)
{
P1=~LED;
LED=LED>>1;
if (LED==0) LED=128;
waitasecond();
}
}
Dùng để hiển thị Led đơn sáng từ trái sang phải.
Ko biết 128 này là kiểu gì vậy thông thường hay xài 0x hoặc 0b thôi kiểu này
#include <REG2051.H>
void waitasecond()
{
unsigned int x;
for(x=0;x<33000;x++);
}
void main()
{
unsigned char LED=128;
while(1)
{
P1=~LED;
LED=LED>>1;
if (LED==0) LED=128;
waitasecond();
}
}
Dùng để hiển thị Led đơn sáng từ trái sang phải.
Ko biết 128 này là kiểu gì vậy thông thường hay xài 0x hoặc 0b thôi kiểu này

Comment