'************************************************************
' Programa: sonar_sr1.bas
' Autor: Sergio Costa
' Data: 18/08/2006
'
'
www.roboticafacil.com.br
'
' Compilador: BASCOM
' Interace: CPU - Robotica Facil Symphony
' Objetivo: medir distância com sonar symphony SR-1
' e mostrar no LCD Serial
'
' Observações: A comunicacao com o sonar é feita pela portb.7 da
' placa CPU
' A comunicação com LCD serial é feita pela porta serial
' da CPU (TX)
'
' valores mostrados em centimetros
'
'************************************************************
'
$regfile = "m8def.dat"
$crystal = 8000000
$baud = 9600
Dim Dist As Word , Strdist As String * 8 , Serdist As Byte
Wait 5
Open "comb.7:9600,8,n,1,INVERTED" For Input As #1
Do
Input #1 , Strdist
Strdist = Right(strdist , 3)
Serdist = Val(strdist)
Printbin &HFE ; &H0D;
Serdist = Serdist * 2.54
Print "Dist = " ; Serdist ; " cm";
Waitms 250
Loop