umogi_lvr wrote: I found out that I need to set the feet of the microcontroller to digital (which is logical of course), but unfortunately MPLAB doesn't recognize ANSEL, ANSELH or ADCON command words for some reason.
The only analog pins on a PIC16F874A are in PORTA and PORTE.
The ports you are using (PORTB and PORTD) are digital only.
If you had been using PORTA, you have to write to ADCON1 to set the pins to digital mode. That is documented under "EXAMPLE 4-1: INITIALIZING PORTA" in the PIC16F874A datasheet.
Also, the delay function is not correct, but i don't know how to add Nop(); or __delay_ms() from lib-pic30.h (mplab doesn't recognise it).
lib-pic30.h is for a different compiler altogether, not XC8.
The XC8 User Guide tells you how to implement delays.
In short, it won't work with this code because you have commented out the #define for _XTAL_FREQ
That #define must be present for the _delay_ms() and __delay_us() macros to work.