Sounds good.
How do you make it do one thing when the button is pressed and another when it is not? Like while pressed make a motor run and then stop when not pressed without it being a seprate button?
Thanks for the help
Sounds good.
How do you make it do one thing when the button is pressed and another when it is not? Like while pressed make a motor run and then stop when not pressed without it being a seprate button?
Thanks for the help
Try this way it should do what you need.Code:main: Pause 200 if portb.0 = 1 then gosub pressed0 if portb.1 = 1 then gosub pressed1 if portb.2 = 1 then gosub pressed2 if portb.3 = 1 then gosub pressed3 goto main pressed0: toggle portb.4 return pressed1: toggle portb.5 return pressed2: toggle portb.6 return pressed3: toggle portb.7 return end
See TOGGLE command on manual.
Al.
Last edited by aratti; - 25th January 2009 at 00:53.
All progress began with an idea
Dave, let him discover the Toggle instruction.
Al.
All progress began with an idea
The toggle wasn't waht I was looking for. I did try it. When you hold down the button and the toggle was going - on/off/on/off etc.....
Thanks for all the help. I am sure I will be posting more questions as I move forward.
Thanks again -
Keith
Hi Keith,
Looks like a classic IF THEN ELSE to me.
make sure to use resistors pulling down if you close switches to activate or pulling up if you open switches to activate.Code:TRISB = %00001111 ' 4 upper as outputs 4 lower as inputs IF PortB.0 = 1 THEN ' if true then goto next statement PortB.4 = 1 ' turn on this port ELSE ' goes to here if false PortB.4 = 0 ' Turns this port off ENDIF ' ends the if then test for true / false and allows code to continue
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Not sure at all but...
Code:TRISB=%00001111 PORTB=0 Loop: PORTB=(PORTB<<4) PAUSE 200 GOTO Loop
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks