Shop OBEX P1 Docs P2 Docs Learn Events
newbie needs simple help — Parallax Forums

newbie needs simple help

pongmstr2pongmstr2 Posts: 16
edited 2010-07-21 01:58 in Propeller 1
hello all,

i'm working on a project for work that needs to flash an led 30 times in 10 seconds when a button is pressed. I convinced my boss that the propeller was the perfect thing for this. i'm just having some problems with the programming. the hardware i can manage. this is the code i have so far. it works the first time the button is pressed but thats it. I know it is a simple piece of code. can anyone please help me.

pub toggle



repeat
if ina[noparse][[/noparse] 0 ] ==1
dira[noparse][[/noparse]4..9]~~
repeat until outa[noparse][[/noparse]9..4]++ == 60

waitcnt(clkfreq/6 + cnt)
dira~

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-07-21 00:27
    Without being able to see indentation I cannot tell what your program is doing.
    Have you read the tutorial and PE Kit Labs?· They come with the Propeller Tool.

    dira[noparse][[/noparse]0]~      ' set as input
    dira[noparse][[/noparse]1]~~     ' set as output
    repeat
       repeat until ina[noparse][[/noparse] 0] == 1  ' wait for button
       repeat 60                 ' flash led
          !outa[noparse][[/noparse]1]               ' toggle LED pin
          waitcnt(clkfreq / 10 + cnt) ' wait a while
    

    John Abshier
  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-07-21 01:55
    pong,

    when you paste code into the forum, it's important to use the CODE tags so your indentation is preserved. Paste your code between

    [noparse][[/noparse] code ]

    and

    [noparse][[/noparse] / code ]

    except remove all the spaces I placed within the brackets.

     That way
        your code
           looks like this
    
    
    



    smile.gif
  • pongmstr2pongmstr2 Posts: 16
    edited 2010-07-21 01:58
    thank you all for your help the code i got from john works good and does what i need.
Sign In or Register to comment.