Display text and sending commands to the BASIC Stamp 2.
Introduction:
First you need to set you LCD to 9600 baud, please consult your displays manual as to how to do this. Then you need to either set your LCD for TTL levels or add a RS232 chip to you circuit. For setting the LCD to TTL levels, please consult the manual for your display.
Setup:
You will need to connect the LCD to the Basic Stamp. We used one of our serial cables, cut the end off and then soldered connectors to pin #2, #3 and #5.
Pin #2 is connected to P0
Pin #3 is connected to P1
Pin #5 is connectod to Vss, which is ground
You can also communicate through the power header, please consult the displays manual to see if it's possible on the model you have.
Code Examples
Sending text to the screen:
Code: Select all
'{$STAMP BS2}
SEROUT 1, 84, ["HELLO WORLD"]
This will display HELLO WORLD on your display.
SEROUT : is the command to send serial information out
1 : is Serial Port #1
84 : is the speed at which the information is sent at, in our case 9600bps.
Sending a Command to the display:
Code: Select all
'{$STAMP BS2}
SEROUT 1, 84, [254] 'Command Prefix
SEROUT 1, 84, [88] 'Clear screen command
In this example the command to clear the screen is sent to the display. Every command requires a "Command Prefix". In Matrix Orbital displays, that's Hex: FE Decimal: 254 ASCII: 254, you can send these bytes in any format you want, as long as you do it properly. In our example we sent them as DECIMAL...
Setting the Backlight to go off in 2 minute:
Code: Select all
'{$STAMP BS2}
SEROUT 1, 84, [254] 'Command Prefix
SEROUT 1, 84, [66] 'Backlight ON command
SEROUT 1, 84, [2] 'Setting the number of minutes to be on
To permanently turn the backlight on, you would send 0 as the third byte. When the display recieves the command, it will know how many more bytes of information it should get. In th backlight on case, the display knows to expect one more byte of information.
Henry J.
President
Matrix Orbital