My recent successes with my Christmas star have got me a request from a neighbour for lighthouse flashing circuit for his model lighthouse. No problem with flashing routines,\however the requirement is to have automatic shutdown (battery saving). To achieve this with a 16f628a I have fed the pic via a pnp switching transistor (2n3906) base is pulled up with 4.7k
and connected to porta.1 via 22k. To start up a pushbutton is also connected to the 22k which pulls the base to 0 and switches on the transistor. This works OK ---HOWEVER I wish to use the same pushbutton to change the flashing routine therefore I have to free up the pushbutton and make porta.1 an input. In order to do this I have connected an identical \transistor switch to portb.0 to hold the supply on whilst using porta.1 as an input. This does not work and I can't for the life of me figure out why. The effect that this produces is that the "power" on led in the circuit lights (at very slightly less than full brightness) then when I press the button (i.e. switch on the transistor which is driven from Porta.1) the flashing routine commences but only continues whilst I hold the button down and then after 12 flashes freezes with the flashing led on ! What the devil is going on ? The code I have written is as follows . Hope I have made this clear without attaching the circuit (haven't figured out how to do that yet... will have another look tomorrow. Cheers

[@ DEVICE pic16f628a,intrc_osc_noclkout,mclr_on

x var word
output portb.0
output portb.3
output porta.1
output porta.0
porta.1 = 0
portb.0 = 0

input porta.1

for x = 1 to 12

high portb.3
pause 200
low portb.3
pause 200
next x
end
]