I tried using very basic delay code in SK40C with PIC 16f877a but it did not work!!According to C logic it should work but in real life it wasnt working!!can you help me know why??Its just a very simple Program!!not much detailed!!
SW1=RBO
LED1=RB6
unsigned int count;
Void main(void)
{
while(1)
{
If(SW1==0)
{
count++;
while(count<20)
{
LED1=1;
delay(4000);
LED1=0;
}
}
}
}
When I write this code the LED never blinks even if use the DelayMS(20); why??Also If I write the code in this way, the easiest one!!it still doesnt work:
If(SW1==0)
{
LED1=1;
delay(4000);
LED1=0;
}
According to it when SW1 is pressed once on SK40C the led should be on for delay value then off!!bt in real life it remains on for ever why??How to rectify this problem!!I dont' want to use interrupt or timers as it is going to make my program really confusing!!So plz tell me the way without using interrupts and timers!!
Also if possible plz tell how to count in PIC,I mean when I press SW1 the count increases by 1 only, Then when i press SW1 again the count increase by 1 until it reaches 20!!then led lights up!!I tried many combinations!!bt as soon as I press my SW1 once the LED is on after sometime without reaching count 20!!
Plz help!!this might seem easy!!bt once u try it doesnt work!!I tried a lot bt cant reach any where!!actually I need to control my servo position using the digital sensor!!
If IR==1
then servoON();
DelayMs(20);
servoOFF();
I tried it bt its not working!!using of timer module is not possible now!!as it seems really confusing!!and i dont have time to put in my code!!If possible plz explain using basic delay!!Thanks a lot!!Help would be really appreciated!!
I never thought such a small thing can create such a big ptoblem!