sang dan, tat dan 2 portb, portd
//sang dan, tat dan 2 portb, portd
#include "16f877a.h"
#include "def_877a.h"
#use delay(clock=4mhz)
char i,j,k,n;
//chuong trinh con tat dan
void tatdan()
{
portb=0x00;
portd=0x00;
k=0x00;
delay_ms(50);
j=0b00000001;
for(i=1;i<=8;i++)
{
k=k|j;
portd=k;
portb=k;
delay_ms(50);
j<<=1;
}
}
//chuong trinh con sang dan
void sangdan()
{
portb=0xff;
portd=0xff;
k=0xff;
delay_ms(50);
j=0b11111110;
for(i=1;i<=8;i++)
{
k=k&j;
portb=k;
portd=k;
delay_ms(50);
j<<=1;
}
}
//chuong trinh chinh
void main()
{
trisb=0;
trisd=0;
while(true)
{
for(n=1;n<=3;n++)
sangdan();
for(n=1;n<=3;n++)
tatdan();
}
}
Bạn đang đọc truyện trên: Truyen247.Pro