Mode Select help.
jdolecki
Posts: 726
How do i write a program to select three different machine modes from one push button?
Machine has 3 modes
Stop
Run
Automatic
Push Push button on input P0 and the machines to the next mode.
I have been readig "whats a micro controller " book but cant find any examples.
thanks
john
·
Machine has 3 modes
Stop
Run
Automatic
Push Push button on input P0 and the machines to the next mode.
I have been readig "whats a micro controller " book but cant find any examples.
thanks
john
·
Comments
This just sits in a loop waiting for the button to be pressed. When pressed, it increments "state" wrapping around at 3. You'll need to add something to this loop to give feedback to the user, perhaps a red/green LED that lights red for stop, green for run, and orange (red and green) for automatic. You'd need to add other code to this loop to provide for the actual action to be performed.
I found an example in the book and im trying to adapt thay to what i need but still having trouble.
You Wrote:
··state·=·0
check:
··button·P0,0,255,0,work,0,check
··state·=·(state·+·1)·//·3
··goto·check
State = 0·· This line set's the "State"· word to zero correct? Why is it called "State" can it be called something else? What is state, a memory location?
Check:·· ( is the programs name?)
Button ( Why is it called Button? can it be called something else?)
P0,···· ·( Is the input, i get that)
0,······· ( is the beginning of the Word bit?)
255,··· (255 max·of the word?)
0,······ ( I dont understand)
Work,· ( I dont understand)
0,·······(I dont understand)
check··( check is the name of the program but why is it here?)
state =······ ( Again what is state)
( state +1)··( Adds 1 to the "state" count)
// 3··········· ( means count to 3 before starting over?)
goto check···( returns back to the beginning of the program)
Thanks for taking time to explain.
·
The label "check:" is pretty simple Basic. I suggest you download a copy of the "What's a Microcontroller?" tutorial and go through it. It's a good introduction to the basics of Basic for the Stamps.
Post Edited (Mike Green) : 1/20/2009 9:20:33 PM GMT
Last Question.
Is "Syntax" the correct term to use when talking about the "button" command?
The data/numbers after the·Button command are called what?·Variables?
Thanks again