PIC Vietnam

Go Back   PIC Vietnam > Robotics > Cảm biến

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

Cảm biến Camera, siêu âm, hồng ngoại, gyro, la bàn...

Trả lời
 
Ðiều Chỉnh Xếp Bài
Old 25-09-2008, 06:50 PM   #1
anh_gioi
Đệ tử 6 túi
 
Tham gia ngày: Oct 2006
Bài gửi: 147
:
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???
anh_gioi vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
Trả lời


Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 09:50 AM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam