BS and LCD how do I?
jdolecki
Posts: 726
I want my Serout commant to reference a place were I would have Foward, Backwards, Left ,Right stored.
How do I move Foward,backwards , left and right in and out of that place?
Do i store it in a Var called Word?
What would I replace "Running Mode" with in this line?
SEROUT 15,n9600,[" Running Mode!"] ' Print message. to tell it go look in the storage spot.
Here is what I have
thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
N9600 CON $4054 ' Baudmode-9600 bps inverted. Use $40F0 for BS2-SX.
I CON 254 ' Instruction prefix value.
CLR CON 1 ' LCD clear-screen instruction.
DO
IF (IN12 = 0) THEN
GOSUB Battery
ELSEIF (IN12 = 1) THEN
GOSUB Running
ENDIF
LOOP
GOSUB Running
GOSUB Battery
END
Running:
PAUSE 1000
SEROUT 15,n9600,[I,CLR] ' Clear the LCD screen.
PAUSE 1
SEROUT 15,n9600,[" Running Mode!"] ' Print message.
RETURN
Battery:
PAUSE 1000
SEROUT 15,n9600,[I,CLR] ' Clear the LCD screen.
PAUSE 1
SEROUT 15,n9600,["- Battery Life +"] ' Print message.
RETURN
How do I move Foward,backwards , left and right in and out of that place?
Do i store it in a Var called Word?
What would I replace "Running Mode" with in this line?
SEROUT 15,n9600,[" Running Mode!"] ' Print message. to tell it go look in the storage spot.
Here is what I have
thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
N9600 CON $4054 ' Baudmode-9600 bps inverted. Use $40F0 for BS2-SX.
I CON 254 ' Instruction prefix value.
CLR CON 1 ' LCD clear-screen instruction.
DO
IF (IN12 = 0) THEN
GOSUB Battery
ELSEIF (IN12 = 1) THEN
GOSUB Running
ENDIF
LOOP
GOSUB Running
GOSUB Battery
END
Running:
PAUSE 1000
SEROUT 15,n9600,[I,CLR] ' Clear the LCD screen.
PAUSE 1
SEROUT 15,n9600,[" Running Mode!"] ' Print message.
RETURN
Battery:
PAUSE 1000
SEROUT 15,n9600,[I,CLR] ' Clear the LCD screen.
PAUSE 1
SEROUT 15,n9600,["- Battery Life +"] ' Print message.
RETURN
Comments
depending on what my vehicle is doing.
in the serout command when is says to display "Running mode" i want to access a varable instead
What do i replace "running mode" with to access a varabale that stores the words foward,back,left, right?
SEROUT 15,n9600,[" Running Mode!"] ' Print message.
does that sound better?
You can't store those strings in a Word variable. The best you could do would be to use an array or read in each letter in DATA statements. Too much hassle. Franklin's suggestion is probably the easiest to implement especially since you have limited and short list of possible scenarios. So you would modify the "running:" section to include four conditionals (IF , ELSEIF), for whatever in your project is deeming the movements FOWARD, BACKWARD, LEFT or RIGHT and have the appropriate string printed out. That is to say that you'd ultimately have four SEROUT commands with the four possible strings instead of using a variable. If you are monitoring buttons to determine motion direction, be sure to handle (or understand at least), the possibility of no buttons being pressed or multiple buttons being pressed simultaneously.
Rick
Anyways, using the SELECT...CASE statement would look something like this:
The second method, where you would only update the display when the vehicle's state changed would look something like this:
Note that in either of these examples, I've omitted whatever other logic you might want to write, so you can't just copy and paste these into your code and expect them to work. I would suggest trying to get a better understanding of what you're trying to do and what the code I've written does if you don't already know.