Skip to content

Instantly share code, notes, and snippets.

@Cale
Created January 28, 2010 21:49
Show Gist options
  • Save Cale/289176 to your computer and use it in GitHub Desktop.
Save Cale/289176 to your computer and use it in GitHub Desktop.
// include the library code:
#include <LiquidCrystal.h>
#include <WString.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2, 3, 4, 9, 10, 11, 12);
void setup(){
// set up the LCD's number of rows and columns:
analogWrite(5, 100);
lcd.begin(16, 2);
// initialize the serial communications:
Serial.begin(9600);
lcd.print("Begin.");
}
int readserial(int a) {
// Convert serial data to string
String serstr = String(999);
itoa(a, serstr, 10);
String b = String(1);
b = serstr.substring(0,1);
//lcd.print(b);
if (b == "2") {
lcd.setCursor(0,1);
lcd.print(b);
}
//lcd.print(a, BYTE);
}
void loop()
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
readserial(Serial.read());
// display each character to the LCD
// lcd.write(Serial.read());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment