Hi everyone,
I'm starting to explore on motors specifically on 12v DC motor. Basically first I want to make it stop, turn it half speed and full speed using 10K resistor on PortA.0. Can I apply the following code from markedwards?
Code:
ADCIN 1,AD1 'read channel 1...AN1
AD1 = AD1 >> 6 'justify data

ADJUSTFAN: 
IF AD1 < 2 then FANSPEED = 153 '60% min speed
IF AD1 >= 3 then SPEED = 178 '70%
IF AD1 >= 5 then SPEED = 204 '80%
IF AD1 >= 7 then SPEED = 229 '90%
IF AD1 >= 9 then SPEED = 255 '100%
IF SPEED > SPD THEN SPD = SPD + 1 'accelerate
IF SPEED < SPD THEN SPD = SPD - 1 'de-accelerate
hpwm 2,SPD,32760 ' PWM 20,000 Hz
As I understand I need a pic that support HPWM, please forgive me if this may sound very basic but how I connect the assigned port pin to the motor?

I have tried using L298N, which I can stop, turn cwise and ccwise the motor, can I also control the speed and can anyone show simple code how to do this?

Thanks in advance,
joe