ADC to BS2px
livewell
Posts: 2
I have connected a adc to the stamp board and have got the stamp to accurately display the correct binary value. However the way i have done it is very wastefull. Does anyone have a better way of doing this. Atm i have a loop set up which checks the input on the first 8 pins. I have assigned the corresponding binary value of each pin, then the loop just adds it up for a true value. Like i said its not the best way to do it does anyone have a shortcut for me, i would appreciate any help as iam very much a begginer. Here is my loop:
'----Checking Loop
Check:
DO
temp = 0
GOSUB Check1
GOSUB Check2
GOSUB Check3
GOSUB check4
GOSUB check5
GOSUB check6
GOSUB check7
GOSUB check8
GOSUB Display
GOSUB Led
GOSUB checkstp
LOOP UNTIL· (stpbtn = 1)
END
'----Checking Procedure
Check1:
IF V1 = 1 THEN
temp = temp + 1
ENDIF
RETURN
Check2:
IF V2 = 1 THEN
temp = temp + 2
ENDIF
RETURN
Check3:
IF V3 = 1 THEN
temp = temp + 4
ENDIF
RETURN
Check4:
IF V4 = 1 THEN
temp = temp + 8
ENDIF
RETURN
Check5:
IF V5 = 1 THEN
temp = temp + 16
ENDIF
RETURN
Check6:
IF V6 = 1 THEN
temp = temp + 32
ENDIF
RETURN
Check7:
IF V7 = 1 THEN
temp = temp + 64
ENDIF
RETURN
Check8:
IF V8 = 1 THEN
temp = temp + 128
ENDIF
RETURN
'----Checking Loop
Check:
DO
temp = 0
GOSUB Check1
GOSUB Check2
GOSUB Check3
GOSUB check4
GOSUB check5
GOSUB check6
GOSUB check7
GOSUB check8
GOSUB Display
GOSUB Led
GOSUB checkstp
LOOP UNTIL· (stpbtn = 1)
END
'----Checking Procedure
Check1:
IF V1 = 1 THEN
temp = temp + 1
ENDIF
RETURN
Check2:
IF V2 = 1 THEN
temp = temp + 2
ENDIF
RETURN
Check3:
IF V3 = 1 THEN
temp = temp + 4
ENDIF
RETURN
Check4:
IF V4 = 1 THEN
temp = temp + 8
ENDIF
RETURN
Check5:
IF V5 = 1 THEN
temp = temp + 16
ENDIF
RETURN
Check6:
IF V6 = 1 THEN
temp = temp + 32
ENDIF
RETURN
Check7:
IF V7 = 1 THEN
temp = temp + 64
ENDIF
RETURN
Check8:
IF V8 = 1 THEN
temp = temp + 128
ENDIF
RETURN
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen