Thank you for repl
y.
dear mike_2545: i was looking for ardunio code but i cant understand.i am using picbasic pro 2.60 and thanks a lot for resistor suggestion.
dear Ian rogers: my isis simulation is does not work, because i cant programming pic for mz80 sensor.
my isis simulation(TRIAL):
my picbasic pro code:
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
CMCON = 7
Trigger CON 5 ' trigger pulse = 10 uS
Scale CON $200 ' raw x 2.00 = uS
RawToIn CON 889 ' 1 / 73.746 (with **)
RawToCm CON 2257 ' 1 / 29.034 (with **)
IsHigh CON 1 ' for PULSOUT
IsLow CON 0
ULTRA_SONAR VAR PORTA.0
rawDist VAR Word
inches VAR Word
cm VAR Word
TRISA = 1
TRISB = 0
PORTB = 0
LOW ULTRA_SONAR
main:
GOSUB GET_SONAR
' get sensor value
inches = rawDist ** RawToIn ' inch'e dönü?tür
cm = rawDist ** RawToCm
' cm'ye dönü?tür
DO
IF (cm > 40) THEN GOTO LED1
IF (cm < 75) AND (CM > 40) THEN GOTO LED2
IF (cm < 40) THEN GOTO LED3
LOOP
GET_SONAR: ' make trigger 0-1-0
ULTRA_SONAR = IsLow
PULSOUT ULTRA_SONAR, Trigger
PULSIN ULTRA_SONAR, IsHigh, rawDist ' measure echo pulse
rawDist = rawDist */ Scale 'convert to uS
rawDist = rawDist / 2
RETURN
LED1:
PORTB = 0
HIGH PORTB.0
GOTO main
LED2:
PORTB = 0
HIGH PORTB.1
GOTO main
LED3:
PORTB = 0
HIGH PORTB.2
GOTO main
END
This code doesnot fork sharp
is this works for mz80? :S