Shop OBEX P1 Docs P2 Docs Learn Events
what is pins = lkup & %00111111?? — Parallax Forums

what is pins = lkup & %00111111??

hiren97hiren97 Posts: 9
edited 2007-12-05 05:58 in Learn with BlocklyProp
Hi,

I am writing a BS2 program for traffic light signal,

code is :

' {$STAMP BS2}
' {$PBASIC 2.5}
' pin5 EW/Red
' pin4 EW/yellow
' pin3 EW/green

' pin2 NS/Red
' pin1 NS/yellow
' pin0 NS/green

'Traffic Signal Project
'
'


NSgo VAR Byte
NSgo = %0000100000100001
NSyel VAR Byte
NSyel = %0000001000100010
allRed VAR Byte
allRed = %0000000010100100
EWgo VAR Byte
EWgo = %0001000000001100
EWyel VAR Byte
EWyel = %0000001000010100

' === Other Constants ===
day VAR Byte
day = 8
night VAR Byte
night = 4


PushBtn PIN 6

' commented out
'INPUT 6
'NScar VAR Byte
'NScar = IN6

phCell VAR Byte
phCell = 7

'===Variables====
seq VAR Byte
seq = B11
qSecs VAR Byte
qSecs = B10
lkup VAR Byte
lkup = W4
time VAR Byte
time = W4
minTime VAR Byte
minTime = W3
dark VAR Byte
dark = B5

'====Program=====
DIRS = %00111111
again:
GOSUB dayNite
FOR seq = 0 TO 5
LOOKUP seq, [noparse][[/noparse]NSgo, NSyel, allRed, EWgo, EWyel, allRed], lkup 'Get bits..
pins = lkup & %00111111
time = lkup /64

FOR qSecs = 1 TO time
PAUSE 250

IF seq <> 3 OR NScar = 1 THEN continue

IF qSecs > minTime THEN changeLight

continue:
NEXT
changeLight:
NEXT
GOTO again

dayNite:
....some code here...
RETURN






Now, what is pins here :

this is BS2 progams...how do I set pins to that output....any ideas ?


Please help, running out of time,

Hiren Patel
hiren97@yahoo.com

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-12-05 02:01
    Read the help files that comes with the program editor. It's all explained in there. If part of that confuses you, ask here.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-05 05:58
    What you have there is a program for the BS1 Stamp which is a little different from the BS2 Stamp.
    Look at Table 4.1 and Table 4.2 on pages 82-83 in the Basic Stamp Manual for details. For setting
    the pins to output, use OUTL (which uses pins 0-7) and use DIRL instead of DIRS. DIRS will work,
    but it's a 16 bit register rather than the 8 bit register on the BS1. Also, as you will see from the
    tables, the input and output registers are different.
Sign In or Register to comment.