Trích:
Nguyên văn bởi shakespeare_a18
Code:
#include <16f887.h>
#fuses HS, MCLR
#use delay (clock=2000000)
int8 mode,i;
byte temp;
#INT_EXT
void isr_ext()
{
mode++;
if (mode==3) mode=0;
}
void program1();
void program2();
void main()
{
enable_interrupts(INT_ext) ;
ext_int_edge(H_TO_L);
enable_interrupts(GLOBAL) ;
mode=0;
while(1)
{
// TODO: USER CODE!!
output_b(0x00);
delay_ms(500);
switch (mode)
{
case 0: program1();break;
case 1: program2();break;
}
}
}
void program1()
{
set_tris_b (0x00);
output_b(0xf0);delay_ms(300);
output_b(0xff);delay_ms(100);
}
void program2()
{
temp=0xff;
for (i=0;i<=8;i++)
{ output_b(temp);
delay_ms(150);
temp <<=1;
}
}
Bác viết sai chính tả hơi nhiều nên nó báo lỗi đó.
|
cam on bac !! minh thuc hien dc roi!!