Ðề tài: code pic12f629
View Single Post
Old 14-05-2018, 03:45 PM   #1
Xuân_Trường
Nhập môn đệ tử
 
Tham gia ngày: May 2018
Bài gửi: 1
:
code pic12f629

Mong các bác giải thích đoạn code sau:

code lập trình trên phần mềm pic c

#include <12F629.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
//#FUSES NOCPD //No EE protection
#FUSES PROTECT //Code not protected from reading
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#use delay(clock=8000000)

int1 TT;

void pip_1();
void pip_2();

void main()
{
set_tris_a(0x04);
TT=0;
output_low(pin_a0); output_low(pin_a1);
setup_comparator(NC_NC);

while(TRUE)
{
if(input_state(PIN_A2)==0)
{
delay_ms(50);

while(input_state(PIN_A2)==0);
TT=~TT;
delay_ms(50);

if(TT==1)
{pip_1();output_high(pin_a0);}
if(TT==0)
{pip_2();output_low(pin_a0);}


}


}
}

void pip_1()
{
output_high(pin_a1);
delay_ms(50);
output_low(pin_a1);
}
void pip_2()
{
output_high(pin_a1);
delay_ms(20);
output_low(pin_a1);
delay_ms(20);
output_high(pin_a1);
delay_ms(20);
output_low(pin_a1);

}

Cám ơn nhiều
Xuân_Trường vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn