top of page

Short Range Proximity Sensor

This program displays the analog output from the sensor as a bar gauge. The sensors analog output goes to pin a1. The analog output of the sensor is scaled between 0 and 100 by the gvr command.

Program


---

Short Range Proximity Sensor Program

This program disoplays the analog output

from the sensor as a bar gauge.

The sensors analog outpout goes to pin a1.

tmt3Nndt

---


prog_vars =

d/line_length 0

prog_vars.


prog_start =

pclear

print "Program Start"

-- Setup the pin as an analog input.

gvr a1 0 100

ptl 10 10 ^ts=24^ "Distance"

-- Add the quit button

pb 150 20 ^n=Quit^p=exitprog^

prog_start.


prog_loop =


-- main program loop

-- Invert the line so it goes up as the value does.

sub -1 /a1 -> /line_length

-- Plot the sensor value

pvl 50 175 /line_length ^lw=10^

-- Display the value

ptl 45 175 ^id=dis^ts=24^ "/a1"

-- Short delay

d250

prog_loop.

prog_stop =

ptl 10 10 ^ts=24^ "Bye"

prog_stop.



bottom of page