Doesn't RBO and RB1 and so fourth supply 5+ to the pin?
In your case RB0 is an input so it is looking for 0 volts to 1.2 volts for a LOW and 3.6 volts to 5 for HIGH. It is best to use a pull up or pull down resistor so the pin will be 0 or 5 and not floating around. Another part or two but I like using external pulls and not rely on the internals.
So, when the sensor is sending its high signal to the PIC and connected to the PIC, what is the voltage.
Try making the pin high or low with out the sensor.
Dave
Always wear safety glasses while programming.
Ok so I tried it with an led and it was working so I am guessing it is the servo
the potentiometer must be broken in the servo
When I get the new servo in the mail I will try it out
thanks everyone
by the way once everything works I will put up a "How to" for this automatic toilet flusher
once I am done.
Just in case anyone else wants to build it
Glad you found the problem!
Just curios, what servo are you using?
Dave
Always wear safety glasses while programming.
Well I still don't know if it is the servo
because when I compiled and programed it
the led was supposed to stay on and the other was supposed to be low
unless it made contact, then the other led that was low now becomes high and the other led that was high before now becomes low.
Here is the code
LEDSW var PORTB.0
LED1 var PORTB.1
LED2 var PORTB.2
TRISB=%00000001
Loop:
If LEDSW=1 then
High LED1
LOW LED2
else
LOW LED1
HIGH LED2
endif
Goto Loop
End
And....what happens. Does anything light up? Did you try LEDSW HIGH by running a jumper to the +5 bus?
Might help to know the voltage output of the sensor. Possible it needs conditioned before the PIC. Even it the voltage is correct the current may not be high enough to over come the pull down resistor.
Dave
Always wear safety glasses while programming.
One LED stays on until the sensor makes contact
but the other one does nothing.
Bookmarks