{{
Operate LED based on switch position
Demonstrates input and output in assembly
392
+3.3─────┳─────┐
│ ┫SW1
100k │ │
pin 2────┘ 
470
pin 3────────┐
│

}}
con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
var
pub Main
'Launch assembly code into cog 1
coginit(1, @switch, 0)
dat
org 0
switch mov mask1, #1
shl mask1, #2
andn outa, mask1 'make pin 2 an input
mov mask2, #1
shl mask2, #3
or dira, mask2 'make pin 3 an output
or outa, mask2
:start test mask1, ina wc 'set carry flag if bit set
if_c andn outa, mask2 'button up - LED off
if_nc or outa, mask2 'button down - LED on
jmp #:start
mask1 res 1
mask2 res 1
Comments
This setup and code is guaranteed to work at my house on my propeller professional development board.
. .
Post Coding
beeeeeep beep-beep