Shop OBEX P1 Docs P2 Docs Learn Events
StampWorks Experiment #4 — Parallax Forums

StampWorks Experiment #4

lockadoclockadoc Posts: 115
edited 2007-11-09 19:48 in BASIC Stamp
··· I am trying to modify the program to work with 11 LEDS instead if the 8 and at the same time controll a servo to follow the LEDS . I just got the Professional Development Board and don't have the full grasp of writing programs yet.

··· I would like some help pointing me in the right direction.

·································· THanks Bill

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-08 14:05
    If you look at the program carefully, you'll see that the names OUTL and DIRL are used for the group of 8 I/O pins and these are byte values. Look in the PBasic manual in the section on memory storage and you'll see that there are various names for the I/O registers, some for 4 bit slices, some for 8 bit slices, and a set for the full 16 bits. Basically, you want to change to the names for the full 16 bit registers and you want to use the least significant 11 bits of those (and change other constants appropriately). Start with that ...
  • lockadoclockadoc Posts: 115
    edited 2007-11-09 17:38
    Thank You, I had an idea of what I was looking for ,you explained it better than what I was getting out of the book. Again thanks Bill
  • lockadoclockadoc Posts: 115
    edited 2007-11-09 19:48
    THanks to Mike Green for the help,
    Now that I got it working with 11LEDS , I noticed and every third pass it would not light up LED #8. Is it becuase of the DelayTm being changed or trouble elsewhere?

    Here is the code that I'm using.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    [noparse][[/noparse] Program Description ]
    '
    ' "Modified
    'Ping-Pongs" a single LED back-and-forth across a bank of eight. This
    ' program will work, unmodified, on any BS2-family module.
    '
    [noparse][[/noparse] I/O Definitions ]
    LEDs VAR OUTS ' LEDs on P0 - P10
    LEDsDirs VAR DIRS ' DIRS control for LEDs

    '
    [noparse][[/noparse] Constants ]
    DelayTm CON 75 ' delay time for lit LED
    '
    [noparse][[/noparse] Initialization ]
    Reset:
    LEDS = %00000000001 ' start with right LED on
    LEDsDirs = %11111111111 ' make LEDs outputs
    '
    [noparse][[/noparse] Program Code ]
    Main:
    REVERSE 8
    DO WHILE (LEDs < %10000000000) ' test for left extreme
    PAUSE DelayTm ' on-time for lit LED
    LEDs = LEDs << 1 ' shift LED left
    LOOP
    DO
    PAUSE DelayTm
    LEDs = LEDs >> 1 ' shift LEDs right
    LOOP UNTIL (LEDs = %000000000001) ' test for right extreme
    GOTO Main


    THanks.... BIll
Sign In or Register to comment.