PDA

View Full Version : programming



jawad28
24-04-2008, 21:52
hi
guys

i need some help? i am doing the project on ultrasonic car parking sensor,i have used a one sensor(srf005) and it seems to be working ok.i have used a following programme

Symbol soundport = 1
Symbol delaytime = w1
Symbol range = w1
Symbol trigport = 0
Symbol echoport = 1

Main:

pulsout trigport, 2
Pulsin echoport, 1, range
Pause 10
Sound soundport, (105, 20)
If range < 500 Then ne
Range = 500
ne:
Pause range
Goto main

now the problem is i want to add another sensor(srf005) it means i have to do some changes in the programming so it can activate both sensor same time and gives the ouput same time.i have used speaker as a output.could anyone please help me to do the programme,i am using PIC 16F88.
rgds:
jawad

hippy
25-04-2008, 00:55
It's not possible to do two things at the same time but you can do one thing after another in fairly quick succession.

Rename 'trigport', 'echoport' and 'range' as 'trigport1', 'echoport1' and 'range1' then create another PulsOut/Pulsin using 'trigport2', 'echoport2' and 'range2'.

You'll want the closest of the two ranges to work with so you can then use -

range = range1 Max range2

This gets the lowest of two values - Yes, "Max" is correct !

From there you can work with 'range' just as you did before.