i am new here,my name is zulaikha n i am a student
now i just start study pic in my uni..n i am trying to do blinking led.
i googling for the sourcecode n o found this
- CODE: SELECT_ALL_CODE
-----------------------------------------------------------------------------------------------------------------------------
// PIC16F877A LED Blinking
//===============================================================
//device definition header file
#include <htc.h>
//device configuration bit
__CONFIG(0x3F3A);
//define
#define LED1 RB7
#define LED2 RB6
//function prototype
void blink_LED1(unsigned char n);
void blink_LED2(unsigned char n);
//main function
//================================================================
void main(void)
{
//device peripheral configuration
TRISB7=0; //set RB7 as output
TRISB6=0; //set RB6 as output
//infinity loop
while(1)
{
//blink LED1 for 3 times
blink_LED1(3);
//blink LED2 for 3 times
blink_LED2(3);
}
}
//function to blink LED1 for n times
void blink_LED1(unsigned char n)
{
//loop for n times
for(n+=1;n>0;n-=1)
{
//set LED1 to 1
LED1=1;
//short delay
for(unsigned int i=0;i<20000;i+=1); //max value is 65535
//set LED1 to 1
LED1=0;
//short delay
for(unsigned int i=0;i<20000;i+=1); //max value is 65535
}
}
//function to blink LED2 for n times
void blink_LED2(unsigned char n)
{
//loop for n times
for(n+=1;n>0;n-=1)
{
//set LED2 to 1
LED2=1;
//short delay
for(unsigned int i=0;i<20000;i+=1); //max value is 65535
//set LED2 to 1
LED2=0;
//short delay
for(unsigned int i=0;i<20000;i+=1); //max value is 65535
}
}
---------------------------------------------------------------------------------------------------------------------
what i understand from the prgram is blink 2 led for 3 times.this is sound really basic for u but for me it is new world!
now i want to modified the program..iam going to used variable capsitor so that i can controlled the speed of led blinking.
i want to make running light that we can controlled the speed of their "running"..for the first time,i want to use 2 led.
can anyone help me plzz..if u can show which part must me added..it really help me..