Hey, can anyone tell me what is the exact code for this application :
I have 3 LED, I want the 3 LED to be ON on seperate time making it like a kind of flow
My code is this :
#include <pic.h>
__CONFIG ( 0x3F32 );
#define LED_1 RC3
#define LED_2 RC2
#define LED_3 RA0
void init(void);
void delay(unsigned long data);
void main(void)
{
init();
for(int i=0;i<10;i++)
{
LED_1=1;
delay(100000);
LED_2=0;
delay(100000);
LED_3=0;
delay(100000);
LED_1=0;
delay(100000);
LED_2=1;
delay(100000);
LED_3=0;
delay(100000);
LED_1=0;
delay(100000);
LED_2=0;
delay(100000);
LED_3=1;
}
}
void init()
{
TRISA=0b00000000;
TRISB=0b00000000;
TRISC=0b00000000;
TRISD=0b00000000;
TRISE=0b00000000;
}
void delay(unsigned long data) //delay function, the delay time
{
for( ;data>0;data-=1); //depend on the given value
}
It does not work as predicted
Help @@@
I have 3 LED, I want the 3 LED to be ON on seperate time making it like a kind of flow
My code is this :
#include <pic.h>
__CONFIG ( 0x3F32 );
#define LED_1 RC3
#define LED_2 RC2
#define LED_3 RA0
void init(void);
void delay(unsigned long data);
void main(void)
{
init();
for(int i=0;i<10;i++)
{
LED_1=1;
delay(100000);
LED_2=0;
delay(100000);
LED_3=0;
delay(100000);
LED_1=0;
delay(100000);
LED_2=1;
delay(100000);
LED_3=0;
delay(100000);
LED_1=0;
delay(100000);
LED_2=0;
delay(100000);
LED_3=1;
}
}
void init()
{
TRISA=0b00000000;
TRISB=0b00000000;
TRISC=0b00000000;
TRISD=0b00000000;
TRISE=0b00000000;
}
void delay(unsigned long data) //delay function, the delay time
{
for( ;data>0;data-=1); //depend on the given value
}
It does not work as predicted
Help @@@