' PILE CODE version 1.0
' portb is our 8 inputs from QPROX: QT113h
' b.0 to b.3 is tops
' b.4 to b.7 is bottoms

define OSC 4

countPeople var byte
sendVal var byte
prevB var byte
time var word
delay var word
delay = 3000 'time before new change occurs in milli secs
pinVar var bit[8]

i var byte
myArray var PORTB

'//////////////////////////////////////////////////////////////////
main:
'count number of people at any moment
for i = 0 to 7
IF myArray.0[i] = 1 then
countPeople = countPeople + 1
endif
next

'make a nice button = check if there is a difference
If portb != prevB then
gosub val
prevB = portB
time = 0
else
time = time+1
endif

if time >= delay then
SEROUT2 portc.6, 16468, [DEC sendVal, 13]
endif

'////////////
val:
select case countPeople
case 0
sendVal = 00 'waiting
CASE 1
sendVal = PORTB
CASE 2
sendVal = PORTB
case is >= 3
sendVal = 10 'party
end select
return

goto main
arrow
arrow
    全站熱搜

    chiahac 發表在 痞客邦 留言(0) 人氣()