PDA

View Full Version : pulsout...servo...LEDs



electroken
- 27th July 2011, 20:59
While learning about pulsout useage, I added LEDs to parts of my simple servo control program. I got the servo moving just fine, but the LEDs never come on. Using an 84A and LEDs on B.4-B.6 and servo on B.0. Push buttons on A.0 and A.1. with pulldown resistors. This is where I am...

define osc 4
j var byte:speed var byte: portb=0:trisa=%00011
speed=50: porta.2=1' power to pic is on LED
main:
portb.6=1: portb.0=0' input loop LED on and clear servo pin
if (porta.0=1 and porta.1=1) then autosweep
if porta.0=1 then portb.4=1: pulsout portb.0,200: pause speed: portb.4=0:goto main
if porta.1=1 then portb.5=1: pulsout portb.0,70: pause speed: portb.5=0:goto main
portb.6=0:goto main
autosweep:
portb.4=1:for j=1 to 30: pulsout portb.0,200: pause speed:next j: portb.4=0
portb.5=1:for j=1 to 30: pulsout portb.0,70: pause speed:next j: portb.5=0
if porta.0=1 then main
if porta.1=1 then main
goto autosweep
end

None of the LEDs light while in the loops. Why? The servo works fine.

cncmachineguy
- 28th July 2011, 00:01
just for fun try this:


speed=50: porta.2=1' power to pic is on LED
portb.4 = 1
portb.5 = 1
portb.6 = 1
pause 2000
main:



This way you have a 2 second all on to verify they all work, it will also tell you what loop turned them off (i think). If they both go off, its autosweep, else if only 1 goes off its the first part