Hi everyone,
I was adamant in getting this to work by myself I've been working on it over the past 2 days but really cant figure it out! This is what I want my code to do:
Do nothing until RB1 is high with momentary tactile switch and then when it is, to jump into the loop to blink the LED connected to RB0. I want the loop to go around 5 times (Therefore the LED to turn on 5 times) then exit the loop back to the start and again wait for RB1 to go high.
What it does is go into the loop but is not responsive to my "i <= N". For this code it loops through 9 times where as I only want it to loop 5 times! When I adjust delay settings it will blink for longer/shorter. It just seems i<= 5 has no effect..
I believe it has something to do with Config or Delay ..
I was adamant in getting this to work by myself I've been working on it over the past 2 days but really cant figure it out! This is what I want my code to do:
Do nothing until RB1 is high with momentary tactile switch and then when it is, to jump into the loop to blink the LED connected to RB0. I want the loop to go around 5 times (Therefore the LED to turn on 5 times) then exit the loop back to the start and again wait for RB1 to go high.
What it does is go into the loop but is not responsive to my "i <= N". For this code it loops through 9 times where as I only want it to loop 5 times! When I adjust delay settings it will blink for longer/shorter. It just seems i<= 5 has no effect..
I believe it has something to do with Config or Delay ..
Code:
#include <htc.h>
#include <pic.h>
#include <pic16f88.h>
#define _XTAL_FREQ 4000000
int main(void)
{
OSCCON = 0x60;
TRISB = 0b00000010;
int i;
if (RB1 = 1)
{
if (i <= 5)
{
RB0 = 1;
__delay_ms (500);
RB0 = 0;
__delay_ms (500);
i++;
}
}
}