NKC Electronics

NKC Electronics Support, Project and Discussion Forums
It is currently Wed Oct 18, 2017 7:03 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Oct 24, 2012 10:06 am 
Offline

Joined: Thu Sep 08, 2011 9:59 pm
Posts: 71
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);
}


Top
 Profile  
 
PostPosted: Wed Oct 24, 2012 9:37 pm 
Offline

Joined: Thu Sep 08, 2011 9:59 pm
Posts: 71
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group