RGB LED blinking in Induino R5

/*
 * main.c
 */

#include <avr/io.h>
#include <util/delay.h>
//#define PIN 0
int main(void)
{
    DDRB|= 1<<PB4;
    DDRB|= 1<<PB5;
    DDRD|= 1<<PD3;//Green
    DDRD|= 1<<PD5;//Blue
    DDRD|= 1<<PD6;//Red

    while(1)
    {
        PORTB|=1<<PB4;
        _delay_ms(100);
        if( PORTB & (1<<PB4) ) // if PB4 set
            PORTB&=~1<<PB4; //unset it

        PORTB|=1<<PB5;
        _delay_ms(100);
        if( PORTB & (1<<PB5) )
            PORTB&=~1<<PB5;

        PORTD|=1<<PD5;
        //PORTD|=1<<PD5;
        //PORTD|=1<<PD6;

        _delay_ms(40);

        PORTD&=~1<<PD5;
        //PORTD&=~1<<PD5;
        //PORTD&=~1<<PD6;
    }
}

//PORTB&=~( (1<<3)|(1<<4)|(1<<5) );//Bitwise NOT (set the OUTPUT as LOW)

About PraveenMax
My Interests: ------------------ Programming , Drawing & Music

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: