So im doing an assignment on blinking leds. I Know there are other posts about this but i have a different question.
I'm familiar with how programming works but this is just confusing.
So when i run this code i get a blinking diode witch is good. but idont understand how to code works. i have to use this code because it was in the assignment. So i get that n is an integer. starts with 0 and theN goes n = n+1 every time the while loop loops to infinity. the thing is. the led is supposed to light only when n is bellow 0
"if(n<0){
PORTC = 0b00000010;
}"
and n never goes down below 0. so why am i getting the led blinking ? How does this program read code or how does the microcontroller read the code ?
The code is in C language. Im using a PICKIT 3 with PIC16F690.
I'm familiar with how programming works but this is just confusing.
C:
/*
* File: newmain.c
* Author: TestSubjectNR97
*
* Created on September 30, 2017, 12:10 PM
*/
#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
#pragma config WDTE = 0; /* Watchdog timer OFF */
int main(int argc, char** argv) {
TRISC = 0b00000000;
TRISB = 0b01100000;
ANSEL = 0b00000000;
ANSELH = 0b00000000;
int n;
while(1){
if(n<0){
PORTC = 0b00000010;
}else{
PORTC = 0b00000000;
}
n=n+1;
}
return (EXIT_SUCCESS);
}
"if(n<0){
PORTC = 0b00000010;
}"
and n never goes down below 0. so why am i getting the led blinking ? How does this program read code or how does the microcontroller read the code ?
The code is in C language. Im using a PICKIT 3 with PIC16F690.