Skip to content

Instantly share code, notes, and snippets.

@rescurib
Last active February 23, 2019 04:50
Show Gist options
  • Save rescurib/ead706ac38f0fbefe97df55ac4788c42 to your computer and use it in GitHub Desktop.
Save rescurib/ead706ac38f0fbefe97df55ac4788c42 to your computer and use it in GitHub Desktop.
#include "config.h"
#include <xc.h>
//#define _XTAL_FREQ 48000000
void init(){
TRISBbits.TRISB0 = 0; // RB0 - salida
TRISDbits.TRISD0 = 1; // RD0 - entrada
ANSELDbits.ANSD0 = 0; // AN20 - desactivado
}
void main(void) {
init();
while(1){
if(PORTDbits.RD0 == 1)
LATBbits.LATB0 = 1;
else
LATBbits.LATB0 = 0;
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment