Shop OBEX P1 Docs P2 Docs Learn Events
Ironing out a program — Parallax Forums

Ironing out a program

ArchiverArchiver Posts: 46,084
edited 2004-05-11 07:30 in General Discussion
Hi,

Can anyone suggest how to iron out the wrinkled logic here so I can
understand how to fix it? The application is to start counting
wraps on a farm hay wrapper and stop at 16. Also pause and count
reset functions are supported. The back function is supposed to
reverse the progression of a center-off valve that leaks. Somehow I
just can't seem to structure this program so it's clear.

Thanks,
Kirk Fraser


'{$STAMP BS1}
SYMBOL BTWK0 = B0
SYMBOL BTWK1 = B1
SYMBOL BTWK2 = B2
SYMBOL BTWK3 = B3
SYMBOL BTWK4 = B4
SYMBOL BTWK5 = B5
SYMBOL BTWK6 = B6
SYMBOL COUNT = B7

MAIN:
COUNT = 0
LOW 6
LOW 7

START:
BUTTON 0, 0, 255, 250, BTWK0, 0, HALT
GOSUB WRAP

HALT:
BUTTON 1, 0, 255, 250, BTWK1, 0, RESET
DONE:
GOSUB HOLD

RESET:
BUTTON 2, 0, 255, 250, BTWK2, 0, COUNTER
GOTO MAIN

COUNTER:
BUTTON 3, 0, 255, 250, BTWK3, 0, START
COUNT = COUNT + 1
DEBUG COUNT
IF COUNT = 16 THEN DONE
GOTO START

WRAP:
HIGH 6
LOW 7
SWACT:
BUTTON 4, 0, 255, 250, BTWK4, 0, SWACT
LOW 6
RETURN

HOLD:
LOW 6
HIGH 7
SWOFF:
BUTTON 5, 0, 255, 250, BTWK5, 0, SWOFF
LOW 7
INPUT 3
IF PIN3 = 0 THEN MIDPT
GOSUB BACK
MIDPT:
RETURN

BACK:
LOW 6
HIGH 7
SWBACK:
BUTTON 3, 0, 255, 250, BTWK6, 0, SWBACK
LOW 7
HIGH 6
TOMID:
BUTTON 0, 0, 255, 250, BTWK0, 0, TOMID
LOW 6
RETURN
Sign In or Register to comment.