|
本帖最後由 chenboshiun19 於 2010-10-25 17:26 編輯
想請教各位前輩三個問題
Q1.如果想用七段顯示器顯示出感測數值的話
要如何應用呢!?
希望可以向各位請教方向
Q2.以下是飆機器人所以提供的超音波測距程式、我們想藉此程式去抓取數值到七段顯示器上的話
要使用get指令嗎
Q3.以RawToIn CON 889 ' 1 / 73.746 (with **)程式段為例,可以請教各位大大RawToIn CON 889 = "1 / 73.746秒數"
如何計算出來
' -----[ I/O Definitions ]------------------------'定義I/O pin------------
Ping PIN 15
' -----[ Constants ]----------------------------'宣告BAISC Stamp可選擇的晶片組類別-------
#SELECT $STAMP
#CASE BS2, BS2E
Trigger CON 5 ' trigger pulse = 10 uS
Scale CON $200 ' raw x 2.00 = uS
#CASE BS2SX, BS2P, BS2PX
Trigger CON 13
Scale CON $0CD ' raw x 0.80 = uS
#CASE BS2PE
Trigger CON 5
Scale CON $1E1 ' raw x 1.88 = uS
#ENDSELECT
RawToIn CON 889 ' 1 / 73.746 (with **)
RawToCm CON 2257 ' 1 / 29.034 (with **)
IsHigh CON 1 ' for PULSOUT
IsLow CON 0
' -----[ Variables ]------------------------------'宣告變數-------------------------
rawDist VAR Word ' raw measurement
inches VAR Word
cm VAR Word
cm2 VAR Word
' -----[ Initialization ]-------------------------'初始化程式段-------------------------
Reset: 'Clear screen
DEBUG CLS,
"Parallax PING))) Sonar", CR, ' setup report screen
"======================", CR,
CR,
"Time (uS)..... ", CR,
"Inches........ ", CR,
"Centimeters... "
' -----[ Program Code ]---------------------------'主程式碼-------------------------
Main:
DO
GOSUB Get_Sonar ' get sensor value
inches = rawDist ** RawToIn ' convert to inches
cm = rawDist ** RawToCm ' convert to centimeters
DEBUG CRSRXY, 15, 3, ' update report screen
DEC rawDist, CLREOL, '
CRSRXY, 15, 4,
DEC inches, CLREOL,
CRSRXY, 15, 5,
DEC cm, CLREOL
PAUSE 100
LOOP
END
' -----[ Subroutines ]-----------------------------------------------------
Get_Sonar:
Ping = IsLow ' make trigger 0-1-0
PULSOUT Ping, Trigger ' activate sensor
PULSIN Ping, IsHigh, rawDist ' measure echo pulse
rawDist = rawDist */ Scale ' convert to uS
rawDist = rawDist / 2 ' remove return trip
RETURN |
|