If you think so, but I think mikroC would be much easier.
You could send the signal to the controller through IR, so you wouldn't need ADC. But ADC is usually here to be used for reading a value off a pot and then adjusting the PWM duty cycle.
Code:
//Program to generate 25kHz output at RC2(CCP1) pin
//Microcontroller: Microchip PIC18452
//Language: C
//Compiler: mikroC v8.20
//Programmer: Tahmid
void main (void){
TRISC = 0;
PORTC = 0;
ADCON1 = 7;
T2CON = 0;
TMR2 = 0;
PWM1_Init(25000); //25kHz
PWM1_Change_Duty(128); //50% duty cycle
// Choose Duty cycle as such:
// PWM_Change_Duty(x);
// x = ( (Duty Cycle in %) / 100) * 255
// This should be read from the IR signal
// This would control the speed of the motor
PWM1_Start(); //Start PWM
while (1){ //Loop forever
// Whatever else might be needed to be done while PWM is running
}
}
If you just need to turn on/off the motor then you don't need this. PWM is needed only for variable duty cycle, ie, adjusting the motor speed. For simple on/off, you could use a port pin and a transistor/MOSFET and send 1 to the pin to turn motor on or 0 to turn motor off.
Hope this helps.
Tahmid.