Skip to content

Instantly share code, notes, and snippets.

@alexandrebl
Created February 25, 2022 17:56
Show Gist options
  • Select an option

  • Save alexandrebl/0777c3f0029a37f650b7a0279d3f8cf1 to your computer and use it in GitHub Desktop.

Select an option

Save alexandrebl/0777c3f0029a37f650b7a0279d3f8cf1 to your computer and use it in GitHub Desktop.
LedBlinkPIC24FJ128GA204
#include <xc.h>
#include <stdbool.h>
#define FCY 4000000UL
#include <libpic30.h>
#define LED_LD3_RED_LAT LATCbits.LATC5
#define LED_LD3_GREEN_LAT LATCbits.LATC6
#define LED_LD3_BLUE_LAT LATCbits.LATC7
#define LED_LD1_LAT LATAbits.LATA9
#define LED_LD2_LAT LATAbits.LATA10
#define LED_LD3_RED_TRIS TRISCbits.TRISC5
#define LED_LD3_GREEN_TRIS TRISCbits.TRISC6
#define LED_LD3_BLUE_TRIS TRISCbits.TRISC7
#define LED_LD1_TRIS TRISAbits.TRISA9
#define LED_LD2_TRIS TRISAbits.TRISA10
#define LED_ON 1
#define LED_OFF 0
#define INPUT 1
#define OUTPUT 0
int main(void){
LED_LD3_RED_TRIS = OUTPUT;
LED_LD3_GREEN_TRIS = OUTPUT;
LED_LD3_BLUE_TRIS = OUTPUT;
LED_LD1_TRIS = OUTPUT;
LED_LD2_TRIS = OUTPUT;
while(1){
LED_LD3_RED_LAT = LED_ON;
LED_LD3_GREEN_LAT = LED_ON;
LED_LD3_BLUE_LAT = LED_ON;
LED_LD1_LAT = LED_ON;
LED_LD2_LAT = LED_ON;
__delay_ms(1000);
LED_LD3_RED_LAT = LED_OFF;
LED_LD3_GREEN_LAT = LED_OFF;
LED_LD3_BLUE_LAT = LED_OFF;
LED_LD1_LAT = LED_OFF;
LED_LD2_LAT = LED_OFF;
__delay_ms(1000);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment