SparkSoftLCD driver

After trying in vain to get the software serial driver to work with my LCD kit a topic for another time), I discovered the SparkSoftLCD driver which does work for me, is smaller, and only uses one pin.

However, I have run into an issue with the "cursorTo()" command not working. I'm wondering if it's something I'm doing wrong, or some incompatibility with my LCD kit (arduino based) compared to other Serial LCD's (PIC based).

include "SparkSoftLCD.h"

// LCD constants

define LCD_TX 2

define LCD_WIDTH 16

SparkSoftLCD lcd = SparkSoftLCD(LCD_TX, LCD_WIDTH);

int TempPin = 0;

void setup() { // setup lcd pinMode(LCD_TX, OUTPUT); lcd.begin(9600); lcd.clear(); lcd.cursor(0); //Turn the cursor off }

void loop() { int temp = analogRead(TempPin); lcd.clear(); int tempC = 25 + (((temp * 4.88) - 750) / 10); //Adjust the reading to celcius; 10 mV per degree, 4.88mV per count (5V / 1024), 750mv = 25C

lcd.print("Temp: "); lcd.print(tempC); lcd.print((char)223); //send degrees symbol lcd.print("C"); lcd.print((char)10); //send a carriage return // lcd.cursorTo(2,1); //Set the cursor to the bottom row first position

int tempF = ((tempC * 1.8 ) + 32); //Convert to degrees fahrenheit

lcd.print("Temp: "); lcd.print(tempF); lcd.print((char)223); lcd.print("F"); delay(1000); }

Currently I'm sending a carriage return (as shown) which works but it would be nice to use the position command as my project gets more advanced. Any ideas?

I discovered the SparkSoftLCD driver ...

You may have discovered the driver but we have not. In order to determine if you are using it correctly we have to be able to see some information about it.

Just a guess here - if you have a two row display they may be numbered 0 and 1. If you have a four row display they may be numbered 0, 1, 2, 3. In either case '2' is not valid for the bottom row.

... or some incompatibility with my LCD kit (arduino based) compared to other Serial LCD's (PIC based).

There is no uniformity between one serial implementation and the next. Consequently there is no reason to expect that a driver written for one serial display will work with another.

Also - use the 'code' button (#) not the 'quote' button to display code in your post.


I found the code through this website (, so I was hoping someone else might have used it. I could not get the other libraries to work as they all use the software serial libraries directly (even using the demo code and setting up exactly like they say).

The SparkSoftLCD library is listed under the Spark Fun Serial LCD area, but Sparkfun has 2 versions of the boards. I got the arduino based version to be able to easily access more capabilities. By reading the datasheets for each, they seem to be command compatable, but that’s what I’m looking to find out. Unfortunately there isn’t much documentation for this library so it is difficult to determine. Looking through the library code is slow going and isn’t yielding any answers yet.

I tried using 0 and 1 for addressing the rows with no help. Using (1,1) it printed on the last position of the top row, but it cut off the first letter of my next text (???), other combinations functioned as if the command didn’t have any effect. Looking through the code, it does expect a value of 1-4 for the rows though. It seems to be in the command structure somewhere. Here’s the library code:

void SparkSoftLCD::cursorTo( uint8_t line, uint8_t pos ) 

   uint8_t lenAdd = 4;
   	// add 4 to position for 20-char displays
   if( _width == 20 ) 
   	   lenAdd = 4;
   switch(line) {
   	   case 1:
	   case 2:
		 pos += 64;
	   case 3:
		 pos += 20;
	   case 4:
		 pos += 84;
   pos += 128;   
   sendControl( pos );

Sorry about using quotes, I was just trying to use the “advanced” feature of the arduino platform (the “copy for forum” command). With the /code switch, it messed that all up.

I found the code through this website (, so I was hoping someone else might have used it.

What do you mean by "it". There seems to be more than one library (to put it mildly) on that page.

Did you read and do you understand this part of the Sparkfun datasheet?

Set cursor position (0×80)
Following the set cursor position command 0×80, the user must send one more data byte. For a 2×16 display (with 32 digits), the data byte should be between 0 and 31, where 0 is the top left digit of the display and 31 is the bottom right. If a value above 31 is sent, the cursor becomes the remainder of that divided by 32 (i.e. 32 is equivalent to 0, 66 is equivalent to 2).

Did you try using the examples in the Sparkfun "Assembly and Getting Started Guide"?


The library I’m referring to is the one called “SparkSoftLCD” (the title of my post).

I did try to follow the numerous example codes provided, but they all used the Software Serial library which I could not get to work at all. I think it had something to do with the initialization declaration of which I saw 2 different ways in sample code: SoftwareSerial mySerial(2, 3) and SoftwareSerial mySerial = SoftwareSerial(2, 3). I could not get either to work which is why I started looking for alternatives.

The observation you made about the extra byte was the key. I’ve been able to track down that the library I’m trying to use is for the PIC based based boards. It uses the same cursor command of 0x80, but then it uses the lower nibble to set the position. This is the exact same format as the standard parallel LCD library.

However, the Arduino based serial LCD uses a different decoding interface that takes a whole extra byte to get the position information. This is a little easier to program as the serial parser just has to advance the cursor rather than keeping track of the position. I don’t think it is as efficient because it converts the cursor count to a cursor position before each write rather than letting the LCD manage advancing the cursor. I missed the command difference originally because they have the same base command (0x80) The other serial LCD’s list the command as “0x80+” which I figured meant to add an extra byte like the Arduino based serial LCD, instead it means to add just a nibble.

I will try and rewrite the Arduino code in the Serial LCD board to accept the same command as the other Serial LCD’s as they seem to be more common. However, that might be more work than I’m looking for so I might just make a one off fix that makes it work for my purposes. Thanks for the help!