PIC Programmer K150: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 20: Line 20:
* Right click on Source files -> New C Main file
* Right click on Source files -> New C Main file
[[File:Mplabx-2.png|MPLabX - screen 2]]
[[File:Mplabx-2.png|MPLabX - screen 2]]
* Paste the following code into new file
<syntaxhighlight lang="c">
/*
* File:  newmain.c
* Author: mkonicek
*
* Created on September 7, 2014, 10:19 AM
*/
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>
#include <pic16f630.h>
#define _XTAL_FREQ 4000000
// Send bit to RA0
void changeled(int value){
    if(value==0){
        PORTA = 0x00;
    } else {
        PORTA = 0x01;
    }
    __delay_ms(1000);
}
int main(int argc, char** argv) {
    TRISA = 0x00; // Set PORTA as OUTPUT
    for(;;){
        changeled(0);
        changeled(1);
    }
}
</syntaxhighlight>

Navigation menu