Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 3582|回復: 1
打印 上一主題 下一主題

有關SRF05及C語言程式

[複製鏈接]
跳轉到指定樓層
1#
發表於 2011-4-2 13:43:30 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式

其實最近也在摸有關超音波的模組
SRF05
http://www.youtube.com/watch?v=VDAoDyV5PmU這是我在網路上看到的
如果我想做成這樣!程式需要怎麼寫?可以給個方向嗎?還有我是用C語言!想用AT89S51單晶片來驅動這模組
我有找到相關程式可是我看不大懂
我把它貼在網路上(引用至某大生專題)
http://tw.myblog.yahoo.com/b1ob2003/
希望各位大大們能教我一下...
感謝@@
2#
發表於 2011-7-4 00:56:57 | 只看該作者
/*
Arduino example for SRF05
Using a single pin for both trigger and echo.
*/

int duration;                          // Stores duratiuon of pulse in
int distance;                          // Stores distance
int srfPin = 2;                        // Pin for SRF05

void setup(){
Serial.begin(9600);
}

void loop(){
  pinMode(srfPin, OUTPUT);
  digitalWrite(srfPin, LOW);           // Make sure pin is low before sending a short high to trigger ranging
  delayMicroseconds(2);
  digitalWrite(srfPin, HIGH);          // Send a short 10 microsecond high burst on pin to start ranging
  delayMicroseconds(10);
  digitalWrite(srfPin, LOW);           // Send pin low again before waiting for pulse back in
  pinMode(srfPin, INPUT);
  duration = pulseIn(srfPin, HIGH);    // Reads echo pulse in from SRF05 in micro seconds
  distance = duration/58;              // Dividing this by 58 gives us a distance in cm
  Serial.println(distance);
  delay(50);                           // Wait before looping to do it again
}

以上來自:
http://www.robot-electronics.co.uk/acatalog/examples.html
具體可以在裡面看看有沒有C51的軟體代碼
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-5-5 19:44 , Processed in 0.143689 second(s), 7 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表