TextStar as a display for Arduino
'TextStar' has been designed to be a small, easy to use and adaptable LCD display for connection to a UART or serial-enabled device. It is a thin chip on glass display that can be powered directly off an Arduino and simple to use by sending familiar serial print commands.
The data sheet requires a little bit of studying but once you spend a little time with it and decode it you realise how powerful this display is. The following code runs on an Arduino and just use 2 serial pins and +5 volts & ground. The code will display a empty to full bar graph.
/*
3rd Jan 2011 - experiments with Textstar LCD
objectives
1 - connect to screen and display message - done
2 - draw a static graph - done
3 - draw a dynamic graph - done
4 _ read buttons when pressed - not done
5 - display live data from sensors - not done
with thanks to
Rowan Simms (http://rowansimms.com) textstar tutorial
Mikal Hart (http://arduiniana.org) New Soft Serial Libralty
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup (){
Serial.begin(9600);
Serial.println("Arduino & TextStar LCD example");
mySerial.begin(9600);
mySerial.println("Hello, world?");
mySerial.write(12); //clear screen
mySerial.write((byte)254);
mySerial.write('C');
mySerial.write((byte)0);
}
void loop (){
battery();
}
void battery() {
mySerial.write(254); // tells display we are sending a command
mySerial.write(76); // tells the display to go to a line
mySerial.write(1); // clears the line 1 aready for re-filling
Serial.println(" BATTERY LEVEL ");
for (int count = 0; count <=100; count += 5)
{
mySerial.write(254); // tells display we are sending a command
mySerial.write(76); // tells the display to go to a line
mySerial.write(2); // clears the line 2 aready for re-filling
mySerial.write("E "); // Prints an "E"
mySerial.write(254); // tells display we are sending a command
mySerial.write(98); // tells the display we want a Capped Bar Graph
mySerial.write(12); // sets the Capped Bar Graph width in character
mySerial.write(count); // sets the % to be filled
delay(50); // .25s delay
mySerial.write(" F"); // prints an "F"
delay(250); // .25s delay
}
mySerial.write(254); // tells display we are sending a command
mySerial.write(76); // tells the display to go to a line
mySerial.write(2); // clears the line 2 aready for re-filling
Serial.println("E FULL F"); // prints a "FULL" indicator
delay(2500); // 2.5s delay before repeating
}