NKC Electronics
http://forums.nkcelectronics.com/

SerialLCD library for Arduino 1.0
http://forums.nkcelectronics.com/viewtopic.php?f=31&t=1085
Page 1 of 1

Author:  nkcelectronics [ Wed Oct 24, 2012 10:06 am ]
Post subject:  SerialLCD library for Arduino 1.0

This is the library to use the 16x2 and 20x4 Serial LCD modules from NKC Electronics.

SerialLCD library created for i2c, SPI and RS232 (UART) interfaces: https://github.com/downloads/nkcelectronics/SerialLCD/SerialLCD.zip

Example sketch to use the library:
Code:
/*
  NKC Electronics serial display - Custom Characters
 
 Demonstrates how to add custom characters on an LCD  display. 
 This sketch prints "I <heart> Arduino!" and a little dancing man
 to the LCD.
 
  The circuit:
 * LCD SCL pin to Arduino SCL pin or Analog 5
 * LCD SDA pin to Arduino SDA pin or Analog 4
 * LCD VSS pin to GND
 * LCD VDD pin to +5V
 
 Based on the original CustomCharacter example from Arduino
 */
 
#include <SerialLCD.h>
#include <Wire.h>
 
// make some custom characters:
byte heart[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b11111,
  0b01110,
  0b00100,
  0b00000
};

byte smiley[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b00000,
  0b00000,
  0b10001,
  0b01110,
  0b00000
};

byte frownie[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b00000,
  0b00000,
  0b00000,
  0b01110,
  0b10001
};

byte armsDown[8] = {
  0b00100,
  0b01010,
  0b00100,
  0b00100,
  0b01110,
  0b10101,
  0b00100,
  0b01010
};

byte armsUp[8] = {
  0b00100,
  0b01010,
  0b00100,
  0b10101,
  0b01110,
  0b00100,
  0b00100,
  0b01010
};

// Constructor.  Parameters: rows, columns, baud/i2c_address, interface (RS232, I2C, SPI)
SerialLCD lcd(2,16,0x28,I2C);

void setup() {
 
  // Initialize LCD module
  lcd.init();
 
  // create a new character
  lcd.createChar(0, heart);
  // create a new character
  lcd.createChar(1, smiley);
  // create a new character
  lcd.createChar(2, frownie);
  // create a new character
  lcd.createChar(3, armsDown);
  // create a new character
  lcd.createChar(4, armsUp);
   
  // Set Contrast
  lcd.setContrast(40);
  // Set Backlight
  lcd.setBacklightBrightness(8);
 
  lcd.home();
  lcd.displayVersion();
  delay(2000);
  lcd.clear();
  lcd.displayBaudRate();
  delay(2000);
  lcd.clear();
  lcd.displayI2CAddress();
  delay(2000);
  lcd.clear();
 
  // Write some text to the display
  lcd.home();
  lcd.print("I ");
  lcd.write((byte)0);
  lcd.print(" Arduino! ");
  lcd.write(1);
}

void loop() {
  // read the potentiometer on A0:
  int sensorReading = analogRead(A0);
  // map the result to 200 - 1000:
  int delayTime = map(sensorReading, 0, 1023, 200, 1000);
  // set the cursor to the bottom row, 5th position:
  lcd.setCursor(2, 5);
  // draw the little man, arms down:
  lcd.write(3);
  delay(delayTime);
  lcd.setCursor(2, 5);
  // draw him arms up:
  lcd.write(4);
  delay(delayTime);
}

Author:  nkcelectronics [ Wed Oct 24, 2012 9:37 pm ]
Post subject:  Re: SerialLCD library for Arduino 1.0

New version uploaded with added support for SPI interface and made minor corrections to the RS232 interface. I also added the examples folder with several demonstrations using RS232, i2c and SPI interfaces.

The library is now hosted in github: https://github.com/nkcelectronics/SerialLCD

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/