/** serout.osc * shows a way to use the serial port with a serial LCD. * Requires 3.0.5 beta or newer compiler. */ oSerial LCD = new oSerial; Byte pw2; Boolean pw1; Word pw3; Sub void main(void) { setUpLCD; LCD.String = "Hello World."; printf; printWord(28012); printf; } sub void setUpLCD(void) { //initialize the serial channel LCD.Baud = cv9600; //9600 baud LCD.Mode = 0; //asynchronous LCD.Operate = cvTrue; //turn it on clearScreen; } sub void clearScreen(void) { sendCmd(12); sendCmd(2); } Sub void sendCmd(Byte d) { //send commands out LCD.Value = 16; //LCD command LCD.Value = d; } Sub void printf(void) { //Send a character LCD.Value = 13; LCD.Value = 10; } Sub void printWord(Word wt) { //Print out a word, byte, nibble or bit value pw1 = 0; pw2 = 0; for (pw3 = 1;pw3 < 20000;pw3*=10) { pw2 = wt/(10000/pw3); if ((pw2 > 0) | (pw1 == 1) | (pw3==10000)){ wt = wt - pw2 * (10000/pw3); pw1 = 1; LCD.Value = pw2 + 48; } } }