I know this code is a little wanky but I get it to the section (I'll mark it with a '*') where I'm displaying, through 'debug', 'PULSE' and a value in variable B0. I expect to display the value B0 initially obtained from section/label: 'LOOK' but instead I get usually) a number '1' or '0'. Missing something in there.
Not sure if the pasting of the code is infuriating. If it is then what's the best way to show it on the forum?
'****************************************************************
'* Name : Bob.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2021 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 11/16/2021 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
PAUSE 10
DEFINE DEBUG_REG PORTC
DEFINE DEBUG_BIT 1
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
DEFINE DEBUG_PACING 1000
TRISA=52
TRISC=32
ANSELA=0 'turn off A/D
ANSELC=0
CM1CON0=0 'turn off comparators
CM1CON1=0
CM2CON0=0
CM2CON1=0
OSCCON=%01101010
DEFINE OSC 4
debug $FE, $58 'clear screen
pause 10
B0 var byte 'here's where you store #miliseconds
B0=0 'put a '0' in there
B1 var byte 'button debounce 1
B1=0
B2 var byte 'button debounce 2
B2=0
B3 var byte 'button debounce 3
B3=0
show:debug $FE, $58 'clear screen
debug dec B0 'show B) value
pause 100
Look:BUTTON porta.4,1,255,10,B1,1,Startup 'plus's B0
button porta.5,1,255,10,B2,1,Startdown 'minus's B0
button portc.5,1,255,10,B3,1,FIRE 'start looking to check sensor pulse
goto look
Startup:B0=B0+1 'add 1 unit
debug $FE, $58
debug dec b0
goto look
Startdown:B0=B0-1 'minus 1 unit
debug $FE, $58
DEBUG DEC B0 'show value of milliseconds on screen
GOTO look 'keep looking for up-down values and FIRE
FIRE:debug $FE, $58
debug "PULSE=",dec B0 'show screen B0 value in 'FIRE' mode
Pause 100
button portc.5,1,255,10,B3,1,show 'go to back to beginning
if porta.2=1 then HIT 'looking for sensor 'on'
'P
goto FIRE
HIT:B0=B0*100 'makes screen value true milliseconds 'convert number to milliseconds
pulsout portc.2,B0 'turn relay on #milliseconds
B0=B0/100 'brings count back to screen value
Goto FIRE
Not sure if the pasting of the code is infuriating. If it is then what's the best way to show it on the forum?
'****************************************************************
'* Name : Bob.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2021 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 11/16/2021 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
PAUSE 10
DEFINE DEBUG_REG PORTC
DEFINE DEBUG_BIT 1
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
DEFINE DEBUG_PACING 1000
TRISA=52
TRISC=32
ANSELA=0 'turn off A/D
ANSELC=0
CM1CON0=0 'turn off comparators
CM1CON1=0
CM2CON0=0
CM2CON1=0
OSCCON=%01101010
DEFINE OSC 4
debug $FE, $58 'clear screen
pause 10
B0 var byte 'here's where you store #miliseconds
B0=0 'put a '0' in there
B1 var byte 'button debounce 1
B1=0
B2 var byte 'button debounce 2
B2=0
B3 var byte 'button debounce 3
B3=0
show:debug $FE, $58 'clear screen
debug dec B0 'show B) value
pause 100
Look:BUTTON porta.4,1,255,10,B1,1,Startup 'plus's B0
button porta.5,1,255,10,B2,1,Startdown 'minus's B0
button portc.5,1,255,10,B3,1,FIRE 'start looking to check sensor pulse
goto look
Startup:B0=B0+1 'add 1 unit
debug $FE, $58
debug dec b0
goto look
Startdown:B0=B0-1 'minus 1 unit
debug $FE, $58
DEBUG DEC B0 'show value of milliseconds on screen
GOTO look 'keep looking for up-down values and FIRE
FIRE:debug $FE, $58
debug "PULSE=",dec B0 'show screen B0 value in 'FIRE' mode
Pause 100
button portc.5,1,255,10,B3,1,show 'go to back to beginning
if porta.2=1 then HIT 'looking for sensor 'on'
'P
goto FIRE
HIT:B0=B0*100 'makes screen value true milliseconds 'convert number to milliseconds
pulsout portc.2,B0 'turn relay on #milliseconds
B0=B0/100 'brings count back to screen value
Goto FIRE
Comment