Logic Input Detector

This program turns Port A pins a1 and a2 into logic inputs with pullup resistors so that they are naturally at logic level 1. Shorting them to ground will make them 0. We use the any statement to detect when they are low.

Program


---

Logic Input Detector

This program turns port A pins a1 and a2 into

logic inputs with pullup resistors so that they

are naturally at logic level 1.

Shorting them to ground will make them logic level 0.

We use the any statement to detect when they are low.

---

prog_vars =

d/count 5

prog_vars.


prog_start =

print "Setup Program"

/d1 0

-- Set Port A1 & A2 as inputs with pullups

spm a1 1

spm a2 1

prog_start.


prog_loop =


-- Check if pin A1 is Low, turn User Led off

any /a1 = 0 -> /d1 0

-- Check if pin A1 is High, turn User Led on

any /a1 = 1 -> /d1 1

-- Check if pin A2 is Low, turn C1 off

any /a2 = 0 ->

c1 0

enda.

-- Check if pin A2 is High, Turn C1 on

any /a2 = 1 ->

c1 1

enda.

prog_loop.


prog_stop =

print "Bye"

prog_stop.