Shop OBEX P1 Docs P2 Docs Learn Events
Turning on LED using PropGCC — Parallax Forums

Turning on LED using PropGCC

tj_saggutj_saggu Posts: 3
edited 2012-09-25 05:23 in Propeller 1
Just wondering how I can turn on an LED using the GCC in simpleIDE.

thanks

Comments

  • RsadeikaRsadeika Posts: 3,837
    edited 2012-09-23 03:42
    There are no built in functions for this, not sure why. You have to include <propeller.h> in your program. It would also help if you show us your code, meaning, what have you tried so far.

    Ray
    #include <propeller.h>
    
    void high(int WCpin)
    {
        unsigned int bits = 1 << WCpin;
        DIRA |= bits;
        OUTA |= bits;
    }
    
    void low(int WCpin)
    {
        unsigned int mask = 1 << WCpin;
        DIRA |= mask;
        OUTA &= ~mask;
    }
    
  • RsadeikaRsadeika Posts: 3,837
    edited 2012-09-25 05:23
    I must of scared the OP with my terse answer, so here is how it is done.

    Ray
    /**
     * @file basicLED.c
     * This is the main basicLED program start point.
     */
    #include <propeller.h>
    
    
    void high(int WCpin)
    {
        unsigned int bits = 1 << WCpin;
        DIRA |= bits;
        OUTA |= bits;
    }
    
    void low(int WCpin)
    {
        unsigned int mask = 1 << WCpin;
        DIRA |= mask;
        OUTA &= ~mask;
    }
    
    /**
     * Main program function.
     */
    int main(void)
    {
        high(0);
        sleep(1);
        low(0);
        high(1);
        sleep(1);
        low(1);
        return 0;
    }
    
    
Sign In or Register to comment.