Hi Group,

I'm fairly new at PIC programming and I'm having a problem writing correct
PicBasic code.
If someone would be so kind as to tell me what I've done wrong, I'd be
totally greatful!

This is how it should work:

I'm using PortB to read 8 switches. If any of these switches are closed (5
volts on any PortB pin)
I want to put 5 volts out on PortA pin 0. This part of my program seems to
be ok.

Now, after any or all of the PortB inputs have been high and ALL have gone
low, I want
to put 5 volts out on PortA pin 1 for 3 seconds. This part of my program
seems to fail often!

Thanks for any help you may be!

Below, is the code I'm trying to use:

'The new Komatsu water truck at Wyodak has a serious problem.
'Drivers have left the water pump switch on with no spray heads
'turned on. This severly overheats the hydraulic system resulting
'in pump and valve failures.
'I've been asked to come up with a fix for it!
'This device was designed to allow the water pump to only run
'when at least one of the spray heads is turned on. There is
'only one exception to this rule. At times, there may be the
'need to run the pump for fire control. In this case an
'input from a switch on the console will act as a spray head switch
'allowing the pump to run.
'We must provide two outputs, one to turn the pump on (RA0)and another
'to turn the pump off (RA1 High for 3 seconds)!
'
'Designed and Programmed for: Wyodak's Water Truck
'Code Author: Lauren Barta
'Designed and edited with: PicBasic
'Started On: 04/06/2006
'Modified On: 05/18/2006
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
Symbol TRISB = 134 'Symbol For TrisB Is Decimal 134
Symbol TRISA = 133 'Symbol For TrisA Is Decimal 133
Symbol PORTB = 6 'Symbol For PortB Is Decimal 6
Symbol PORTA = 5 'Symbol For PortA Is Decimal 5


Poke 134, 255 'Makes All PortB Pins Inputs
Poke 133, 0 'Makes All PortA Pins Outputs

Start:

Poke 5, 0 'Makes PortA Pins Low
Pause 10 'Short Pause

Run:
LET B2 = 0 'Making B2 a zero
Pause 10 'Short Pause
Peek PortB, B0 'Look at PortB, put results in B0
IF B0 = 0 Then Start 'If all PortB pins are low, go to Start

Run2: 'Or Run2 if B0 is not equal to zero

Poke 5, 1 'Makes PortA Pin (RA0) High and will turn the pump on!
Pause 10 'Short Pause
Peek PortB, B2 'Look at PortB again, put contents in B2
Pause 10 'Short Pause
IF B2 > 0 Then Run 'If B2 is greater than 0, go to run

Run3: 'Or Run3 if B2 is equal to zero

Pause 10 'Short Pause
Poke 5, 2 'Makes RA0 Low and RA1 High and turns the pump off!
Pause 3000 'Wait 3 seconds
Call Start 'Start all over again!

End