After blowing up my last LCD module used for a project, I decided to buy a new one, and decided on this RGB back-light module from Sparkfun. It shares the standard pin-out as any Arduino compatible module (the 4/8-bit parallel Hitachi HD44780 interface), and includes a back-light that can be illuminated using an RGB LED.

I made the requisite connections for use on my Spark Core, and after discovering that the LED K connection is to ground and that the contrast adjustment pin requires a voltage of more than 4.5V (So grounding on a 3.3V system such as the Core is not enough) I had the module running nicely. As an additional feature, I connected the blue LED terminal via a BC457b transistor to allow control via software. Future expansion could include RGB PWM control for some funky effects, perhaps.

After playing around with setting text in the Spark IDE, I expanded the firmware to allow reception of text from a POST request, and then created such a request in Android to allow control of the back-light and text shown in app form. After a bit of layout attention, this was the result. The font size and margins are chosen to wrap the same as the LCD (Word wrapping is a novel feature of the Core firmware I wrote).

Screenshot_2014-05-04-21-31-28The small size of the LCD module image is due to the fact I couldn’t find any on the internet larger (later I may create my own), and scaling it up proved unsightly. Still quite legible on my Nexus 5 display, however. Entering the above text and hitting ‘SET’ gives the following real-world result:

IMG_20140504_213246The font isn’t exactly the same, but close enough for my own use. I think that on any other sized display some more advanced layout management would be required, but that is for a future time. Also featured in the above picture, but unused, is the ADXL362 accelerometer I also used with the Core after tweaking the Arduino library to run, but haven’t written about yet.

Two useful code snippets I created for re-use in future LCD projects are sending the Spark Cloud request in Android:

public static String cloudRequest(String deviceId, String accessToken, String functionOrVariableName, String argString) {
	try {
		//Setup connection
		URL url = new URL("" + deviceId + "/" + functionOrVariableName);
		HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
		String urlParameters = "access_token=" + accessToken + "&args=" + argString;

		//Send request
		DataOutputStream wr = new DataOutputStream(con.getOutputStream());

		//Receive response
		BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
		String inputLine;
		StringBuffer response = new StringBuffer();
		while ((inputLine = in.readLine()) != null) {

		return response.toString();
	} catch (Exception e) {
		System.err.println(SparkUtils.class.getName() + ": Exception:");
		return "FAILED";

And also performing simple word wrapping between lines 0 and 1 of the LCD display:

//Check overrun
if(msg.charAt(15) != ' ' && msg.charAt(16) != ' ')
    //Find start of offending word
    int index = 15;
    while(msg.charAt(index) != ' ' && index >= 0)

    String one = msg.substring(0, index);
    String two = msg.substring(index + 1);

    lcd.setCursor(0, 1);

I’ve embarked upon my fourth and final year at university, and so a lot of my time is taken up with the course and associated course-work, including a mammoth individual research project.

The good news is that a large part of that project will involve writing software in C++, which I’ve never used before. I have, however, used C so the leap is not too far. Thus over the last week or so I’ve been gaining familiarity with using the OpenCV image processing library and after the initial teething troubles installing and linking the library it looks very promising for what I hope to achieve.

In the free time remaining when I’m not doing other life stuff, I’ve been working on a much more polished GClient using the knowledge I obtained working on Watch Trigger, as well as trying to figure out why zoom isn’t working in a test build of Watch Trigger +. Yet more wresting with the finicky Camera API.

Hopefully I’ll crack it soon!