Shop OBEX P1 Docs P2 Docs Learn Events
LEDs row 01234567 — Parallax Forums

LEDs row 01234567

ArchiverArchiver Posts: 46,084
edited 2003-11-12 15:24 in General Discussion
For my leds row I have got the simple code below going. This allows
me to control individually the 8 leds on the stamp by pressing 0 to 7
on my keyboard.
But what should I include in the program to be able to access the
stamp with Visual c++ other then the debug window of the editor?

'{$STAMP BS2}
led0 con 0 ' The first LED
led1 con 1 ' The second LED
led2 con 2 '...
led3 con 3
led4 con 4
led5 con 5
led6 con 6
led7 con 7



progPin con 16 ' The programming pin

ledCmd var byte

low led0
low led1
low led2
low led3
low led4
low led5
low led6
low led7


debug "Started.", cr

ReceiveLoop:
Serin progPin, 84, [noparse][[/noparse]ledCmd] ' Get the serial data


if ledCmd = 48 then led0Toggle
if ledCmd = 49 then led1Toggle
if ledCmd = 50 then led2Toggle
if ledCmd = 51 then led3Toggle
if ledCmd = 52 then led4Toggle
if ledCmd = 53 then led5Toggle
if ledCmd = 54 then led6Toggle
if ledCmd = 55 then led7Toggle

if ledCmd = 32 then die

goto ReceiveLoop

led0Toggle:
toggle led0
goto ReceiveLoop

led1Toggle:
toggle led1
goto ReceiveLoop

led2Toggle:
toggle led2
goto ReceiveLoop

led3Toggle:
toggle led3
goto ReceiveLoop

led4Toggle:
toggle led4
goto ReceiveLoop

led5Toggle:
toggle led5
goto ReceiveLoop

led6Toggle:
toggle led6
goto ReceiveLoop

led7Toggle:
toggle led7
goto ReceiveLoop

die:
high 0
low 15
pause 333
low 0
high 15
pause 333
low 0
low 15

debug cr, "Finished",cr

stop



--- In basicstamps@yahoogroups.com, "Dave Mucha" <davemucha@j...>
wrote:
> --- In basicstamps@yahoogroups.com, "alberto_frigo" <artdavi@h...>
> wrote:
> > I would like to control a row of leds (i.e. pin 0 to pin 7)
sending
> > data out of my computer (i.e. if I send out 00000010 then the led
> > conncted to pin 2 is turned on). Anybody could help me?
> > Regards,
> > AF
>
> are you talking about lighting LED's from a Stamp or your computer ?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-11-12 13:40
    Alberto-

    Or,

    ReceiveLoop:
    Serin progPin, 84, [noparse][[/noparse]ledCmd] ' Get the serial data
    if ledCmd = " " then die
    OUTL = OUTL ^ (1 << (ledCmd - "0"))
    goto ReceiveLoop

    See the manual regarding SERIN/SEROUT using I/O 16 for info on
    PC<->Stamp serial comm.

    Regards,

    Steve
  • ArchiverArchiver Posts: 46,084
    edited 2003-11-12 15:24
    Replace the 'DEBUG' lines with:
    SEROUT ProgPin, 84, [noparse][[/noparse]"MyString", 13]

    This will send the 'DEBUG' information back
    to C++ on the same serial port you are
    using to talk TO the BS2.

    You might do:
    InDebug CON 1
    ...
    IF InDebug THEN DebugP1
    'ELSE
    SEROUT ProgPin, 84, [noparse][[/noparse]"MyString",13]
    GOTO SkipP1
    DebugP1:
    DEBUG "MyString", 13
    SkipP1:
    ' Rest of Program....


    ' The above code is to allow you to change the
    ' InDebug constant to 1 when you want 'debug' output,
    ' and 0 when you want 'SEROUT' output.
    '

    --- In basicstamps@yahoogroups.com, "alberto_frigo" <artdavi@h...>
    wrote:
    > For my leds row I have got the simple code below going. This allows
    > me to control individually the 8 leds on the stamp by pressing 0 to
    7
    > on my keyboard.
    > But what should I include in the program to be able to access the
    > stamp with Visual c++ other then the debug window of the editor?
    >
    > '{$STAMP BS2}
    > led0 con 0 ' The first LED
    > led1 con 1 ' The second LED
    > led2 con 2 '...
    > led3 con 3
    > led4 con 4
    > led5 con 5
    > led6 con 6
    > led7 con 7
    >
    >
    >
    > progPin con 16 ' The programming pin
    >
    > ledCmd var byte
    >
    > low led0
    > low led1
    > low led2
    > low led3
    > low led4
    > low led5
    > low led6
    > low led7
    >
    >
    > debug "Started.", cr
    >
    > ReceiveLoop:
    > Serin progPin, 84, [noparse][[/noparse]ledCmd] ' Get the serial data
    >
    >
    > if ledCmd = 48 then led0Toggle
    > if ledCmd = 49 then led1Toggle
    > if ledCmd = 50 then led2Toggle
    > if ledCmd = 51 then led3Toggle
    > if ledCmd = 52 then led4Toggle
    > if ledCmd = 53 then led5Toggle
    > if ledCmd = 54 then led6Toggle
    > if ledCmd = 55 then led7Toggle
    >
    > if ledCmd = 32 then die
    >
    > goto ReceiveLoop
    >
    > led0Toggle:
    > toggle led0
    > goto ReceiveLoop
    >
    > led1Toggle:
    > toggle led1
    > goto ReceiveLoop
    >
    > led2Toggle:
    > toggle led2
    > goto ReceiveLoop
    >
    > led3Toggle:
    > toggle led3
    > goto ReceiveLoop
    >
    > led4Toggle:
    > toggle led4
    > goto ReceiveLoop
    >
    > led5Toggle:
    > toggle led5
    > goto ReceiveLoop
    >
    > led6Toggle:
    > toggle led6
    > goto ReceiveLoop
    >
    > led7Toggle:
    > toggle led7
    > goto ReceiveLoop
    >
    > die:
    > high 0
    > low 15
    > pause 333
    > low 0
    > high 15
    > pause 333
    > low 0
    > low 15
    >
    > debug cr, "Finished",cr
    >
    > stop
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "Dave Mucha" <davemucha@j...>
    > wrote:
    > > --- In basicstamps@yahoogroups.com, "alberto_frigo"
    <artdavi@h...>
    > > wrote:
    > > > I would like to control a row of leds (i.e. pin 0 to pin 7)
    > sending
    > > > data out of my computer (i.e. if I send out 00000010 then the
    led
    > > > conncted to pin 2 is turned on). Anybody could help me?
    > > > Regards,
    > > > AF
    > >
    > > are you talking about lighting LED's from a Stamp or your
    computer ?
Sign In or Register to comment.