Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Detecting presence of LCD on Baby-O


I have built a project that uses the baby-O to detect and control the float level in a gas tank and send the proper voltage to the gas gauge to cause it to display the proper fuel level. To allow a user to set up the parameters of the program I have a separate unit that can be plugged into the main unit (the main unit contains the baby-O). This separate unit has an LCD and 3 buttons for the configuration process. When the gas gauge indicates a near empty tank the main unit uses PC4 to light up a yellow LED warning light.

When the main unit is functioning it sends periodic readings to the LCD. When the separate LCD unit is plugged in the readings appear on the LCD. I found that the warning light functions as it should when the separate LCD unit is plugged in but, if it is not plugged in, the warning light may go on and not turn off no matter what the fuel level is or it may not light up when the fuel level goes from being OK to being near empty. If I comment out the LCD print commands and unplug the LCD unit, the warning light works as it should. if I could detect the presence of the LCD I could skip the LCD print code and potentially fix the problem.

Why is this happening and how might I fix it?



Hello, Burke.

I am sorry you are having trouble getting your Baby-O to behave as you expect. Can you tell me more about your setup? What LCD are you using? How is it connected to your Baby-O? Can you post a schematic that shows the connections in your system? Also, if you post the simplest version of your code that shows this behavior, I could take a look.



I am using the same LCD you sell and use on the SV-328. It is connected via a multi-lead cable from the “main” unit to the “configuring” unit. The baby-O is in the “main” unit and the LCD and 3 buttons are in the “configuring” unit. The following attachments are 1. the “main” unit (FuelGaugeDashBox.pdf (42.4 KB)) and 2. the “configuring” unit (FuelGaugeConfigBox.pdf (39.2 KB))

I don’t want to include all the code (don’t know how to format code here) but I use the standard LCD printing commands and use the PC4 pin to power the LED warning light. as shown below:

// send power to the fuel gauge

	set_motors(0,- ui8MotorOutput);

// print fuel gauge volts to LCD

	print_long(lround(dGaugeVoltsToSend * 1000.0));
        // for debugging
	if (bEmptyWarningLightOn)

// code to turn on warning light

#define EMPTY_WARNING_LEVEL ((float)0.094) // turn on light if fuel level below this part of a full tank
bool bEmptyWarningLightOn = FALSE;

void turnOnEmptyWarningLight(bool bTurnOn)
	if (bTurnOn && !bEmptyWarningLightOn)
		// turn warning light on
		set_digital_output(EMPTY_WARNING_LIGHT_PIN, HIGH);
		bEmptyWarningLightOn = TRUE;
	else if (!bTurnOn && bEmptyWarningLightOn)
		// turn warning light off
		bEmptyWarningLightOn = FALSE;


I did not notice anything in your schematic or the snippet of code you provided that could obviously lead to this kind of behavior, and we have not heard of any issues from running Orangutan LCD code without an LCD attached. So, it seems like the issue could be from elsewhere in your program. Could you post your full code? To make your code more viewable on the forum, you can encapsulate it in a set of three back quotes (aka back ticks). You can also click the preformatted text icon in the reply editor, which I have highlighted (in dark gray) in the picture below:


You can also include your code as an attachment.

Additionally, our Orangutan LCD library does not have a function to check if the LCD is connected or not. You might be able to write your own code to detect the presence of the LCD, but it would require some lower-level understanding of the LCD interface.



I just learned that some old versions of our library might cause a problem waiting for an LCD that is not connected. Could you make sure you are using the newest version?



I did not have the latest version of the library. I got it and installed and recompiled. That fixed the problem.

Thanks a lot!