Hello all,
I am trying to increment a while loop and turn on and off an LED with MPLAB X IDE and XC8 compiler. I think its just a standard C conditionl statement, the clean and build comes back as error-free but the LED is initially off, it flashes on for a quarter second then off then back on and stays on.
Im not sure why its doing that. It should flash on, wait a second, flash off wait a second ten times.
I am trying to increment a while loop and turn on and off an LED with MPLAB X IDE and XC8 compiler. I think its just a standard C conditionl statement, the clean and build comes back as error-free but the LED is initially off, it flashes on for a quarter second then off then back on and stays on.
Im not sure why its doing that. It should flash on, wait a second, flash off wait a second ten times.
Rich (BB code):
#include <xc.h>
#include <delays.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 20000000
int main(void) {
TRISB = 0x00;
int k;
k = 0;
while(k < 10)
{
PORTB = 0xFF;
_delay(20000000);
PORTB = 0x00;
_delay(20000000);
k++;
}
return 0;
}