View Single Post
Old 02-03-2013, 11:37 AM   #8
hungcdt_k49
Đệ tử 1 túi
 
Tham gia ngày: Nov 2012
Bài gửi: 19
:
nhân tiện đây cho mình hỏi, giao tiếp cảm biến siêu âm srf05 dùng 18f4431. Mình viết code nhưng không rõ sai ở chỗ nào.

#include <18f4431.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT,NOPUT,NODEBUG
#use delay(clock=12000000)
int8 a,b,c,led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0},tram,chuc,dv,i,j,k;
float s,kc;
int16 time;
#define rc6 pin_C6
#INT_TIMER0
void trantimer1()
{
set_timer1(0);
}
#INT_EXT1
void ngatngoai1()
{
set_timer1(0);
}
void ngatngoai2()
{
time=get_timer1();
kc=(time*4*4)/(12*58);// cong thuc nay da dung chua?????????????????????????????????
}
void hienthi()
{
if(kc>=100)
{
dv=9;
chuc=9;
tram=9;
}
else
{
dv=(int8)kc%10;
chuc=(int8)(kc/10)%10;
tram=(int8)(kc/100)%10;
}
output_b(led[dv]);
}
void trigger()
{
output_high(Pin_C6);
delay_us(12);
output_low(Pin_C6);
}
void main()
{
set_tris_b(0);
set_tris_c(0);
enable_interrupts(INT_EXT1);
enable_interrupts(INT_EXT2);
enable_interrupts(INT_TIMER0);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
EXT_INT_EDGE(1,L_TO_H);
EXT_INT_EDGE(2,H_TO_L);
enable_interrupts(global);
while(1)
{
trigger();
delay_ms(50);
}
}
hungcdt_k49 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn