#ifndef LED_TRIS #define LED_TRIS TRISBbits.TRISB2 #endif #ifndef LED_PIN #define LED_PIN PORTBbits.RB2 #endif #ifndef LED_TRIS2 #define LED_TRIS2 TRISBbits.TRISB1 #endif #ifndef LED_PIN2 #define LED_PIN2 PORTBbits.RB1 #endif // ------------------------------------------------ // this #include pulls in the correct processor-specific registers // definition file #include "pic18fregs.h" void main() { long i; // set pin to output LED_TRIS = 0; LED_TRIS2 = 0; // set pin to input PUSH_TRIS = 1; // sit in an endless loop blinking the led for(;;) { for (i=0; i < 40*330; i++); LED_PIN = 1; LED_PIN2 = 0; for (i=0; i < 40*330; i++); LED_PIN = 0; LED_PIN2 = 1; } }