2x16 lcd ?
electromanj
Posts: 270
Hello all, I purchased a 2x16 serial backlit lcd from parallax last summer and am just getting·time to start learning it. I have had success with downloading text to it using the bs2. The question that I have is how does one go about writing commands that if, say for instance, pin 1 is high than display·this or if pin 14 is low diplay that? Is there a sample code link somewhere that is a little more detailed than what is on the product page for the lcd? I think this lcd will be a really cool addition to any project, however I don't know much about it. Any help would be greatly appriciated. Thanks.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
http://forums.parallax.com/showthread.php?p=531520
Hope it helps you out.
Al
AL- I hadn't seen that link before thanks. I need to read it.
From a quick look am I on the right track?
{$STAMP BS2}
TxPin CON 0
Baud19200 CON 32
HIGH TxPin ' Set pin high to be a serial port
PAUSE 100 ' Pause for Serial LCD to initialize
Do
SEROUT TxPin, Baud19200, [noparse][[/noparse]12]
PAUSE 2000
SEROUT TxPin, Baud19200, [noparse][[/noparse]17]
IF 0 = 1 then
SEROUT TxPin, Baud19200, [noparse][[/noparse]"switch closed."]
SEROUT TxPin, Baud19200, [noparse][[/noparse]CR]
PAUSE 2000
if 0 = 0 then
SEROUT TxPin, Baud19200, [noparse][[/noparse]"switch open."]
loop
Here is a more refined version that will really show how much I don't know.
' {$STAMP BS2}
' {$PBASIC 2.5}
TxPin CON 0
Baud19200 CON 32
INPUT 4
HIGH TxPin ' Set pin high to be a serial port
PAUSE 100 ' Pause for Serial LCD to initialize
SEROUT TxPin, Baud19200, [noparse][[/noparse]12]
PAUSE 2000
SEROUT TxPin, Baud19200, [noparse][[/noparse]17]
DO
IF 4 = 1 THEN
SEROUT TxPin, Baud19200, [noparse][[/noparse]"switch closed."]
SEROUT TxPin, Baud19200, [noparse][[/noparse]CR]
PAUSE 200
ENDIF
IF 4 = 1 THEN
SEROUT TxPin, Baud19200, [noparse][[/noparse]"switch open."]
SEROUT TxPin, Baud19200, [noparse][[/noparse]CR]
PAUSE 200
ENDIF
LOOP
I have made a couple project where i used a LCD This has been awhile that i have used one
One thing i have learned is to use a demo that works and some time use more that one demo·to understand how to control the·LCD to show what you want with in the demo that you are using first use the debug screen and get your main code routine to work first
The reason i am saying this is that in one of the project that·I am working on
I will be using what is this link to learn·more how to use and control this LCD http://forums.parallax.com/showthread.php?p=531520
I· very sorry if i making it sound like i trying to tell you what to i do not mean to
Oper8r Al
Thank You so very much for posting this link this will help me a lot i have already put this on my desk top as a short cut to this post
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 12/22/2007 4:24:03 AM GMT
I just glanced at the code you had and noticed that you had both of your IF = THEN statements set to 1, I assume you meant one of them to be IF 4 = 0 THEN. Other than that I am probably not going to be much help. I am trying to learn this stuff my self and thought I would pass along the link. The best suggestion I have is to read the post and try what you think is right and go from there. If it doesn't work keep trying and I am sure someone with more experience will chime in with more help.
Al
For example what if I wanted to sense the state of a switch and display the value with an LED.
If the switch is closed then the LED is lit.
If the switch is open then the LED is not lit.
Maybe IF THEN isn't even the right command?
I have a very weak grasp of the programming.
I would think that it would go somthing like this:
0 INPUT
1 OUTPUT
IF 0 = 0
THEN HIGH 1
IF 0 = 1
THEN LOW 1
I would try this right now but I only have one LED handy.
I am not the best at this but you should only need one led.
If your switch is normally closed and connected to pin0 and your led is connected to pin1 try
DO
IF INO = 0 THEN HIGH 1
IF IN0 = 1 THEN LOW 1
LOOP
it is late and I'm should be asleep but give this a try. One more suggestion you should check out:
www.parallax.com/Portals/0/Downloads/docs/books/edu/wamv2_2.pdf
it will help you out with the basics.
Al
1. I had forgotten one simple thing. when using the if then you have to use () to specify low and high otherwise you are comparing to pin 1 or pin 0. DUHRRRR!
here's my latest version and it works. The only problem is it only checks the state once and then its over. I would like it to check the state continuously. I tryed do, loop but getting some wierd readouts when it loops.
' {$STAMP BS2}
' {$PBASIC 2.5}
TxPin CON 0
Baud19200 CON 32
INPUT 4
LOW 4
HIGH TxPin ' Set pin high to be a serial port
PAUSE 100 ' Pause for Serial LCD to initialize
DO
PAUSE 2000
SEROUT TxPin, Baud19200, [noparse][[/noparse]17]
IF (IN4 = 0) THEN
SEROUT TxPin, Baud19200, [noparse][[/noparse]"switch open."]
SEROUT TxPin, Baud19200, [noparse][[/noparse]CR]
PAUSE 200
ENDIF
IF (IN4 = 1) THEN
SEROUT TxPin, Baud19200, [noparse][[/noparse]"switch closed."]
SEROUT TxPin, Baud19200, [noparse][[/noparse]CR]
PAUSE 200
ENDIF
LOOP