Shop OBEX P1 Docs P2 Docs Learn Events
is it a syntax error ? — Parallax Forums

is it a syntax error ?

bandrbandr Posts: 3
edited 2009-02-27 01:09 in BASIC Stamp
in a test i tried to do a program like this :

hrdwarely, i connected 3-leds with the pins(4,10,12)

then i wrote this code:


' {$STAMP BS2}
' {$PBASIC 2.5}

r PIN 4

Comments

  • bandrbandr Posts: 3
    edited 2009-02-24 01:00
    sorry for my question"is it a syntax error " because i succeeded in downloading the code to the micontroller but no thing happened.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-24 01:08
    Depending on how you've wired the LEDs, either a HIGH <pin> or a LOW <pin> will turn on the LED on that <pin> and the opposite statement (LOW or HIGH) will turn it off. "cary" is just a bit array and has nothing to do with the LEDs. If you haven't read "What's a Microcontroller?" you should read through it. It's a good introduction to the Stamps and Stamp Basic. You can download it and the Stamp Basic Manual by going to Parallax's main webpage and clicking on the Resources tab, choosing Downloads, then choosing Stamps in Class Downloads. You'll see an index of all the downloadable tutorials. Choosing Downloads, then Basic Stamp Documentation will get you an index that includes a link for the Stamp Basic Manual.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-25 19:12
    Hello,

    Your code is assigning what is at the input for each declared pin to the array immediately following the declaration of the array. One issue is you’re addressing outside the declared array size which starts at 0, not 1. Another is that you assigning values to the cary variable in your loop, but this won’t have any affect on the I/O pins themselves. Perhaps you could try:

    r = 1

    or

    g = 1

    The array is no necessary to address the pins. They can be addressed as an array by themselves. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • allanlane5allanlane5 Posts: 3,815
    edited 2009-02-27 01:09
    You didn't mention any current limiting resistors, like 220 or 330 ohms in series with each LED. If you leave them off entirely, it can destroy the LED when you try to turn it on. Just a thought.
Sign In or Register to comment.