Parallax 2x16 Serial LCD (Backlit)
I'm a college student and I was given an assignment to display the temperature read from a DS1620 on a Javelin Stamp on a Parallax 2x16 Serial LCD. This is the code I have so far:
·import stamp.core.*;
·import stamp.peripheral.sensor.temperature.DS1620;
·import stamp.peripheral.lcd.SerialLCD;
·public class getTemp {
· final static int SERIAL_TX_PIN = CPU.pin0;·· //Pin0 Transmits data back to the terminal
· final static int SERIAL_RTS_PIN = CPU.pin1;
· final static int SERIAL_CTS_PIN = CPU.pin2;
· final static int SERIAL_RX_PIN = CPU.pin3;·· //Pin3 Receives data from the terminal
·
static DS1620 tempReader = new DS1620(CPU.pin4,CPU.pin5,CPU.pin6);·· //Creates a DS1620 variable that holds the temperature
·
static final int LCD_PIN··· = CPU.pin15;
·
static Uart rxUart· = new Uart( Uart.dirReceive, SERIAL_RX_PIN, Uart.dontInvert,
·························· SERIAL_CTS_PIN, Uart.dontInvert, Uart.speed9600,
·························· Uart.stop1 );
public static void main () {
Uart txOut = new Uart(Uart.dirTransmit, LCD_PIN, Uart.dontInvert,
························· Uart.speed9600,Uart.stop1);
SerialLCD myLCD = new SerialLCD(txOut);
·
while (true){
· int itemp=tempReader.getTempC();
· myLCD.clearScr();
· myLCD.write(itemp);
· myLCD.write(" Celsius");
· CPU.delay(10000);
· }
· }
}
The LCD displays " Celsius", but just before it it displays a custom character rather than the actual temperature number. I was wondering if any of you would be so kind as to tell me what I'm doing wrong.
I'm almost positive the problem·is myLCD.write(itemp);
·import stamp.core.*;
·import stamp.peripheral.sensor.temperature.DS1620;
·import stamp.peripheral.lcd.SerialLCD;
·public class getTemp {
· final static int SERIAL_TX_PIN = CPU.pin0;·· //Pin0 Transmits data back to the terminal
· final static int SERIAL_RTS_PIN = CPU.pin1;
· final static int SERIAL_CTS_PIN = CPU.pin2;
· final static int SERIAL_RX_PIN = CPU.pin3;·· //Pin3 Receives data from the terminal
·
static DS1620 tempReader = new DS1620(CPU.pin4,CPU.pin5,CPU.pin6);·· //Creates a DS1620 variable that holds the temperature
·
static final int LCD_PIN··· = CPU.pin15;
·
static Uart rxUart· = new Uart( Uart.dirReceive, SERIAL_RX_PIN, Uart.dontInvert,
·························· SERIAL_CTS_PIN, Uart.dontInvert, Uart.speed9600,
·························· Uart.stop1 );
public static void main () {
Uart txOut = new Uart(Uart.dirTransmit, LCD_PIN, Uart.dontInvert,
························· Uart.speed9600,Uart.stop1);
SerialLCD myLCD = new SerialLCD(txOut);
·
while (true){
· int itemp=tempReader.getTempC();
· myLCD.clearScr();
· myLCD.write(itemp);
· myLCD.write(" Celsius");
· CPU.delay(10000);
· }
· }
}
The LCD displays " Celsius", but just before it it displays a custom character rather than the actual temperature number. I was wondering if any of you would be so kind as to tell me what I'm doing wrong.
I'm almost positive the problem·is myLCD.write(itemp);
Comments
This is because "myLCD.write(itemp);" is not going to send the string representing the temperature, but a byte which will be interpreted as a character number.
Like if your temperature is 32, it will send #32 with is a space. You will have to convert itemp to a char array first and then send the char array to the display.
JM