Các bác cho em hỏi :
Trích:
#define SRF05_IN PIN_C2
#define SRF05_OUT PIN_C3
// Clockrate/(4 clocks per instruction * T1_DIV_BY_4) * 1000000 us per second
#define CONVERT_TO_MICROSECONDS (20000000/((4*4)*1000000))
//
// The way the srf05 works is that we send it a 10 us high pulse it then sends
// out does it's mojo. Then it reports back a high pulse telling you how long
// the ultrasonic echo took. Divide that by a magic 148 and you convert that
// time into inches.
//
int16 ultrasonic_checkDepth()
{
int16 time;
output_high(SRF05_IN);
delay_us(10);
output_low(SRF05_IN);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
while(!input(SRF05_OUT)) {} // Wait for senser output to go high;
set_timer1(0);
while(input(SRF05_OUT)) {}
time = get_timer1();
time = time/CONVERT_TO_MICROSECONDS;
if(time >= 240000)
{
// No object found
return 0;
}
else
{
return time/148; // convert time into inches
}
}
|
nghĩa là khi ban đầu tắt time để dò tìm vật cản, sau khi xác định được vật cản thì bật timer . có phải không ạ??
thứ 2 em hỏi LCD03 là LCD1602 à? hay nó là loại nào???