Re: Use a switch by change not on/off status.
Ok, a JK FlipFlop is a 2 input one output device.
I am guessing you are using a latching relay which
changes states every time it is energised, is
this correct?
If so you need to read 2 pins to check switch state.
Code:
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
DEFINE OSC 4
TrisA = %00000011
TRISC = %00000000
PortC = %00000000
ANSEL=0
ANSELH=0
ADCON0 = 0
ADCON1 = 0
Option_Reg = %00000000 ; enable RABPU
WPUA = %00000011 ;Set RABPU
Main:
If PortA.0 = 0 then
portc.2 = 1
pause 500 ; 1/2 seconds of power out
portc.2 = 0
else
goto main
endif
goto Impatient ; wait for microswitch to zero
Impatient:
while PortA.1 = 1
portc.3 = 1
pause 100
portc.3 = 0
pause 100
wend
if PortA.1 = 0 then goto main
end
Tested with 16F690 demo board. Weak pullups did not work, had to use real resistors, likely because the PICKit2 was still connected. LEDs were enabled to verify operation
Last edited by Archangel; - 23rd November 2014 at 11:43.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks