Hi,
Well first things first..
Here is the code that Cuban posted earlier, with a couple of amendments so it will build ok.
So you need to connect your servo and run this code on it to prove it works.
By following those Servo tutorials mentioned earlier and changing the Delay Values you will start to see how you control the motor.
This method is "software" PWM - good and simple but limiting.
Get this done and proven then you can move on to the Hardware PWM method which means you can easily control 2 servos from each pic.
Look at controlling 5 motors when you have learnt how to do the above.
As you saying you do not know how to connect up the pic and motor - do you need a diagram ?
Let us know what hardware have you got, breadboard, soldering on a strip , psu ,programmer etc
Code:
LIST P=PIC16f877A
#include "p16f877A.inc"
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _LVP_OFF & _CPD_OFF
; Define variables used
CBLOCK 0x20
Delay
Delay1
Delay2
ENDC
ORG 0x00
init:
banksel ADCON1
movlw 0x06 ; all pins digital I/O
movwf ADCON1
CLRF PORTA
Banksel TRISA
CLRF TRISA ; All pins on porta are output
banksel PORTA
loop:
BSF PORTA,1 ;
MOVLW d'249' ; set delay of approx 1.5ms
CALL Delay_1x ;
BCF PORTA,1 ; Turn them off, no more pulse
MOVLW d'18' ; set delay of approx 18ms
CALL Delay_10x ;
GOTO loop ; Start over
;Setup up the delay routines that may be used
;delay of 1ms for 4mHz clock
;
Delay_1ms
Movlw D'166'
Delay_1x ;call here with W set allows diiferent delays
Movwf Delay
delay_loop
Nop
Nop
Nop
Decfsz Delay,f
goto delay_loop
return
;delay of 10ms for 4mHz clock
Delay_10ms
movlw d'10'
Delay_10x ;call here with W set allows diiferent delays
movwf Delay2
Delay_Loop_10ms
Call Delay_1ms ; Call 1ms delay
Decfsz Delay2,f
goto Delay_Loop_10ms
return
end