a simple question that i have searched and found things like using "pin = !pin" ect but obviously this does not work so i am just wondering if their is an easy quick way or command to toggle an output pin between on/off states.
tony
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ok i think ive spent too long not doing this as i seem to have forgotten how to do things.
what i am trying to achieve is to simply control 2 outputs using one pushbutton with a brief push and release toggling output 1 and a push and hold to toggle output 2 but it seems im getting no luck at all.
Have a look at the alternate approach using an interrupt. If you look at you Demo filder in your Great Cow Basic installation there are more interrupt examples.
Anobium
'I changed to 16f so I could test... sorry.
#chip 16f88, 16
#config MCLRE_OFF, BOREN_OFF
'set NOT_WPUEN = 0
'set WPUA.3 = 1
;Input Pin and Direction
#define inpin PORTb.4
#define bttn_led PORTA.2
#define ch2 PORTB.1
#define ch1 PORTB.0
Dir inpin In
dir bttn_led out
dir ch1 out
dir ch2 out
portb = b'00001111'
wait 500 ms
portb = b'00001000'
set ch1 on
On Interrupt portbchange call HandleEvent
; Main Program starts here
Do
Loop
Sub HandleEvent
if ch2 = 1 then
ch1 = 1
ch2 = 0
else
ch1 = 0
ch2 = 1
end if
End sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
a simple question that i have searched and found things like using "pin = !pin" ect but obviously this does not work so i am just wondering if their is an easy quick way or command to toggle an output pin between on/off states.
tony
If you search the Help for Toggle this will show a good method .
If you search the Help for Toggle this will show a good method .
yep seen both of those, the peek solution really doesnt make to much sense to me though.
tony
Last edit: tony golding 2015-09-06
ok i think ive spent too long not doing this as i seem to have forgotten how to do things.
what i am trying to achieve is to simply control 2 outputs using one pushbutton with a brief push and release toggling output 1 and a push and hold to toggle output 2 but it seems im getting no luck at all.
i tried the recommended route of the peek at the entire port but still cannot get any sort of behaviour i expect.
tony
Last edit: tony golding 2015-09-07
well finally got it working, gawd i think ive spent far to much time away from this
Tony, well done.
Have a look at the alternate approach using an interrupt. If you look at you Demo filder in your Great Cow Basic installation there are more interrupt examples.
Anobium