Try a while loop instead of the for loop
Of course you need 2 of these, just like you have 2 for..nextCode:while buttonx=1 run motor pause something wend
Try a while loop instead of the for loop
Of course you need 2 of these, just like you have 2 for..nextCode:while buttonx=1 run motor pause something wend
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Hello CipiCips,
Ok first off make sure you spell words the same way every time Button <> Botton.
Second If you are using R/C servos is there not some setting to cause them to stop ( I am not an R/C guy ) if so perhaps between else and endif you could specify that setting.
I think I would group my code into sub routines and make a main loop which checks the buttons constantly, something like so:
mainloop:
while 1 = 1
if button1 then gosub right
if button2 then gosub left
wend
Do not forget to put return in both sub routines
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.
Follow Joe advice with reference to the wording. Next you should associate the button name to an input pin of your pic. Using the TRIS command make two pins input and then associate them to your buttons alias.
Button1 VAR PORTB.0
Button2 VAR PORTB.1
I have used portB as an example you can use any port you will consider handy.
Remember to place a pulldown resistor (4.7 to 10k) and a 10 nanoFarad across
For debouncing
Cheers
Al.
All progress began with an idea
This is just a comment about variable names. If you set this project aside and come back to it in a while, you might not remember which button turns what way.
Try to use variable names that mean something:
ButtonL
ButtonR
That way you will know at a glance what to expect in your code. It also makes it easier to others if you work in a team environment, or share your code with others.
(you don't have to do this, it's just to help make things clear)
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Bookmarks