DO - RED LED
D1 - GREEN LED
D2 - BLUE LED
Lets see a simple schematic of this
Schematic
This was written using mikroC Pro for PIC, a free evaluation version is available from http://www.mikroe.com/mikroc/pic/
/*
* Project name:
RGB led
*/
void main() {
TRISD = 0; // set direction to be output
do {
LATD = 0xFF; // Turn OFF LEDs on PORTB, common anode RGB LED
Delay_ms(200); // 1 second delay
LATD = 0xFE; // Turn ON RED LED
Delay_ms(200); // 1 second delay
LATD = 0xFF; // Turn OFF LEDs on PORTB, common anode RGB LED
Delay_ms(200); // 1 second delay
LATD = 0xFD; // Turn ON GREEN LED on PORTB
Delay_ms(200); // 1 second delay
LATD = 0xFF; // Turn OFF LEDs on PORTB, common anode RGB LED
Delay_ms(200); // 1 second delay
LATD = 0xFB; // Turn ON BLUE LED
Delay_ms(200); // 1 second delay
LATD = 0xFF; // Turn OFF LEDs on PORTB, common anode RGB LED
Delay_ms(200); // 1 second delay
} while(1); // Endless loop
}
No comments:
Post a Comment