Shop OBEX P1 Docs P2 Docs Learn Events
Propeller C - How to test the state of an output pin? — Parallax Forums

Propeller C - How to test the state of an output pin?

SLincoSLinco Posts: 4
edited 2015-06-22 01:31 in Propeller 1
Hi All,

Finally back after several years away - and now I'm learning C on the Propeller YEAH!

So I'd like to toggle an LED in my main loop - like we can in spin:
!outa[ led ]

Anyone got any idea of the equivalent in C? I've searched, but haven't found anything I understand! I did find the Toggle Tutorials, but whoa they are complex for such a simple requirement.

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2015-06-21 14:14
    The equivalent to "!outa[led]" is "OUTA ^= 1 << led;".
  • SLincoSLinco Posts: 4
    edited 2015-06-22 01:31
    Many thanks Dave,

    I don't think I would've found that. I'll give that a try a.s.a.p.

    YAY - that works :-)

    Turns out that there's also a toggle() function!

    None of the above worked at first, but then I spotted that I had
    while( 1 );
    {
      ...
    }
    
    ... semi-colon where a semi-colon shouldn't be - D'oh!

    Thanks again.
Sign In or Register to comment.