Custom LCD tag powerd by Arduino - Page 1
Forum section: electronics / projects

author: GrandTheftAuto4life
author_rank: Contributor
timestamp: July 19, 2013, 07:25:06 pm
content: Hmm, I got a bunch of lcd's I haven't come up with a use for...I like these led/lcd tags you can buy, but I'd like to make my own one, using mainly parts that I already have...Here is the list of parts I intend to use:NHD-0216K1Z-NS(RGB) (LCD 2x16 chars, HD47780 compatible)Arduino Mini3v coin cells or tripple-A battery solutionArduino sound sensor moduleThis should allow for a pretty slim design even though the lcd module is kinda fat (13 mm).The reason why I have choosen this particular display is that it's the transmissive and has got rgb backlight.(They were intended for another project which I never got around doing anything with)Datasheet:http://www.mouser.com/ds/2/291/NHD-0216K1Z-NS_RGB_FBW-REV1-47051.pdfApplication Note:Antenna would be replaced by a sound sensorNow the questions comes;What do you think about the font?Which battery solution should I go for?Any ideas on how to do nice effects to the music played?Any ideas on how to keep the depth of the final product below 2.5 cm?I would appreciate help regarding the above...If anyone is interested in the code used in the video;Code:#include <LiquidCrystal.h>const int lcd_red = 9;const int lcd_green = 10;const int lcd_blue = 11;const int AudioPin = A7;int AudioValue;int count=0;int textflow=-1;const int RS_pin = 13; // LCD R/S pin connected to Arduino Nano D2const int RW_pin = -1; // LCD R/W pin connected to GND (We won't read data from the display)const int Enable_pin = 12; // LCD R/S pin connected to Arduino Nano D3const int Data_4 = 4; // Upper 4bit data bus line #1 (DB4)const int Data_5 = 5; // Upper 4bit data bus line #2 (DB5)const int Data_6 = 6; // Upper 4bit data bus line #3 (DB6)const int Data_7 = 7; // Upper 4bit data bus line #4 (DB7)// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(RS_pin, Enable_pin, Data_4, Data_5, Data_6, Data_7);// Letter E - Pixels group ONE (First)byte Letter_E_1 = {B11111,B11111,B11000,B11000,B11000,B11000,B11111,B11111,};// Letter E - Pixels group TWO (Second)byte Letter_E_2 = {B11110,B11111,B00000,B00000,B00000,B00000,B11000,B11100,};// Letter E - Pixels group THREE (Third) [Use Letter_E_1 to save LCD RAM]// Letter E - Pixels group FOUR (Fourth) [Use Letter_E_2 to save LCD RAM]// Letter X - Pixels group ONE (First) [Diagonal Line: DownRight]byte Letter_X_1 = {B11000,B11000,B11100,B01100,B01110,B00110,B00111,B00011,};// Letter X - Pixels group TWO (Second) [Diagonal Line: TopLeft]byte Letter_X_2 = {B00011,B00011,B00111,B00110,B01110,B01100,B11100,B11000,};// Letter X - Pixels group THREE (Third) [Use Letter_X_1 to save LCD RAM]// Letter X - Pixels group FOUR (Fourth) [Use Letter_X_2 to save LCD RAM]// Letter I - Pixels group (Only) [Use twice to create the character 'I']byte Letter_I = {B01011,B01011,B01011,B01011,B01011,B01011,B01011,B01011,};// Letter L - Pixels group ONE (First) [Use Letter_I to save LCD RAM]// Letter L - Pixels group TWO (Second)byte Letter_L = {B01011,B01011,B01011,B01011,B01011,B01011,B01000,B01111,};// Letter L - Pixels group THREE (Third) (Uses no pixels)// Letter L - Pixels group FOUR (Fourth)byte Letter_dot = {B00000,B00000,B00000,B00000,B11110,B11110,B00110,B11110,};// Letter F - Pixels group ONE (First) [Use Letter_I to save LCD RAM]// Letter F - Pixels group TWO (Second) [Use Letter_E_2 to save LCD RAM]// Letter F - Pixels group THREE (Third) [Use Letter_I to save LCD RAM]// Letter F - Pixels group FOUR (Fourth)byte Letter_bit = {B11100,B11000,B00000,B00000,B00000,B00000,B00000,B00000,};void setup() {// Set up the audio inputanalogReference(DEFAULT); // 5vSerial.begin(9600); // Data rate between computer and project board// initialize the digital pin as an output.pinMode(lcd_red, OUTPUT);pinMode(lcd_green, OUTPUT);pinMode(lcd_blue, OUTPUT);// set up the LCD's number of columns and rows:lcd.begin(16, 2);// Print a message to the LCD.lcd.print("ExileFox");// Lit the LCD backlightanalogWrite(lcd_red, 247);// Store a custom char on the LCD's memorylcd.createChar(0, Letter_E_1);// Store a custom char on the LCD's memorylcd.createChar(1, Letter_E_2);// Store a custom char on the LCD's memorylcd.createChar(2, Letter_X_1);// Store a custom char on the LCD's memorylcd.createChar(3, Letter_X_2);// Store a custom char on the LCD's memorylcd.createChar(4, Letter_I);// Store a custom char on the LCD's memorylcd.createChar(5, Letter_L);// Store a custom char on the LCD's memorylcd.createChar(6, Letter_dot);// Store a custom char on the LCD's memorylcd.createChar(7, Letter_bit);}// the loop routine runs over and over again forever:void loop() {// Increase countercount++;// Adjust RGB LEDif(count == 33 || count == 66 || count == 100){AudioValue = analogRead(AudioPin); // Store the read valueanalogWrite(lcd_green, AudioValue);if(count == 66){AudioValue = analogRead(AudioPin); // Store the read valueanalogWrite(lcd_red, AudioValue);}else if(count == 100){AudioValue = analogRead(AudioPin); // Store the read valueanalogWrite(lcd_blue, AudioValue);}}else AudioValue = analogRead(AudioPin); // Store the read value// Send data to computer (serial monitor)Serial.println(AudioValue);if(textflow == -1) lcd.clear();// Write custom messageif(count > 100){count=0;textflow++;if(textflow > 32) // Reset LCD{textflow=0; // Reset status of the messagelcd.clear();}if(textflow >= 1) // E{lcd.setCursor(0, 0); // Move cursor up to the top line/rowlcd.write(byte(0));lcd.write(byte(1));lcd.setCursor(0, 1); // Move cursor down to the bottom line/rowlcd.write(byte(0));lcd.write(byte(1));}if(textflow >= 2) // EX{lcd.setCursor(2, 0);lcd.write(byte(2));lcd.write(byte(3));lcd.setCursor(2, 1);lcd.write(byte(3));lcd.write(byte(2));}if(textflow >= 3) // EX I{lcd.setCursor(4, 0);lcd.write(byte(4));lcd.setCursor(4, 1);lcd.write(byte(4));}if(textflow >= 4) // EXI L{lcd.setCursor(5, 0);lcd.write(byte(4));lcd.setCursor(5, 1);lcd.write(byte(5));lcd.write(byte(6));}if(textflow >= 5) // EXIL E{lcd.setCursor(7, 0);lcd.write(byte(0));lcd.write(byte(1));lcd.setCursor(7, 1);lcd.write(byte(0));lcd.write(byte(1));}if(textflow >= 6) // EXILE F{lcd.setCursor(9, 0);lcd.write(byte(4));lcd.write(byte(1));lcd.setCursor(9, 1);lcd.write(byte(4));lcd.write(byte(7));}if(textflow >= 7) // EXILEF O{lcd.setCursor(11, 0);lcd.write(byte(3));lcd.write(byte(2));lcd.setCursor(11, 1);lcd.write(byte(2));lcd.write(byte(3));}if(textflow >= 8) // EXILEFO X{lcd.setCursor(13, 0);lcd.write(byte(2));lcd.write(byte(3));lcd.setCursor(13, 1);lcd.write(byte(3));lcd.write(byte(2));}// EXILEFOX}}Updated codeCode:#include <LiquidCrystal.h>const int lcd_red = 9;const int lcd_green = 10;const int lcd_blue = 11;const int AudioPin = A7;int AudioValue;int count=0;int textflow=-1;const int RS_pin = 13; // LCD R/S pin connected to Arduino Nano D2const int RW_pin = -1; // LCD R/W pin connected to GND (We won't read data from the display)const int Enable_pin = 12; // LCD R/S pin connected to Arduino Nano D3const int Data_4 = 4; // Upper 4bit data bus line #1 (DB4)const int Data_5 = 5; // Upper 4bit data bus line #2 (DB5)const int Data_6 = 6; // Upper 4bit data bus line #3 (DB6)const int Data_7 = 7; // Upper 4bit data bus line #4 (DB7)// initialize the library with the numbers of the interface pinsLiquidCrystal lcd(RS_pin, Enable_pin, Data_4, Data_5, Data_6, Data_7);// Letter E - Pixels group ONE (First)byte Letter_E_1 = {B11111,B11111,B11000,B11000,B11000,B11000,B11111,B11111,};// Letter E - Pixels group TWO (Second)byte Letter_E_2 = {B11110,B11111,B00000,B00000,B00000,B00000,B11000,B11100,};// Letter E - Pixels group THREE (Third) [Use Letter_E_1 to save LCD RAM]// Letter E - Pixels group FOUR (Fourth) [Use Letter_E_2 to save LCD RAM]// Letter X - Pixels group ONE (First) [Diagonal Line: DownRight]byte Letter_X_1 = {B11000,B11000,B11100,B01100,B01110,B00110,B00111,B00011,};// Letter X - Pixels group TWO (Second) [Diagonal Line: TopLeft]byte Letter_X_2 = {B00011,B00011,B00111,B00110,B01110,B01100,B11100,B11000,};// Letter X - Pixels group THREE (Third) [Use Letter_X_1 to save LCD RAM]// Letter X - Pixels group FOUR (Fourth) [Use Letter_X_2 to save LCD RAM]// Letter I - Pixels group (Only) [Use twice to create the character 'I']byte Letter_I = {B01011,B01011,B01011,B01011,B01011,B01011,B01011,B01011,};// Letter L - Pixels group ONE (First) [Use Letter_I to save LCD RAM]// Letter L - Pixels group TWO (Second)byte Letter_L = {B01011,B01011,B01011,B01011,B01011,B01011,B01000,B01111,};// Letter L - Pixels group THREE (Third) (Uses no pixels)// Letter L - Pixels group FOUR (Fourth)byte Letter_dot = {B00000,B00000,B00000,B00000,B11110,B11110,B00110,B11110,};// Letter F - Pixels group ONE (First) [Use Letter_I to save LCD RAM]// Letter F - Pixels group TWO (Second) [Use Letter_E_2 to save LCD RAM]// Letter F - Pixels group THREE (Third) [Use Letter_I to save LCD RAM]// Letter F - Pixels group FOUR (Fourth)byte Letter_bit = {B11100,B11000,B00000,B00000,B00000,B00000,B00000,B00000,};void setup() {// Set up the audio inputanalogReference(DEFAULT); // 5v// initialize the digital pin as an output.pinMode(lcd_red, OUTPUT);pinMode(lcd_green, OUTPUT);pinMode(lcd_blue, OUTPUT);// set up the LCD's number of columns and rows:lcd.begin(16, 2);// Print a message to the LCD.lcd.print("ExileFox");// Lit the LCD backlightanalogWrite(lcd_red, 247);// Store a custom char on the LCD's memorylcd.createChar(0, Letter_E_1);// Store a custom char on the LCD's memorylcd.createChar(1, Letter_E_2);// Store a custom char on the LCD's memorylcd.createChar(2, Letter_X_1);// Store a custom char on the LCD's memorylcd.createChar(3, Letter_X_2);// Store a custom char on the LCD's memorylcd.createChar(4, Letter_I);// Store a custom char on the LCD's memorylcd.createChar(5, Letter_L);// Store a custom char on the LCD's memorylcd.createChar(6, Letter_dot);// Store a custom char on the LCD's memorylcd.createChar(7, Letter_bit);// Reset the LCD backlightanalogWrite(lcd_red, 0);}// the loop routine runs over and over again forever:void loop() {// Increase countercount++;// Adjust RGB LEDif(count == 10 || count == 20 || count == 30 || count == 40 || count == 50 || count == 60 || count == 70 || count == 80 || count == 90){AudioValue = analogRead(AudioPin); // Store the read valueanalogWrite(lcd_green, AudioValue);if(count == 10 || count == 30 || count == 50 || count == 80){AudioValue = analogRead(AudioPin); // Store the read valueanalogWrite(lcd_red, AudioValue);}else if(count == 20 || count == 40 || count == 60 || count == 70 || count == 80 || count == 90){AudioValue = analogRead(AudioPin); // Store the read valueanalogWrite(lcd_blue, AudioValue);}delay(100);}if(textflow == -1) lcd.clear();// Write custom messageif(count > 100){delay(100);count=0;textflow++;if(textflow > 32) // Reset LCD{textflow=0; // Reset status of the messagelcd.clear();}if(textflow >= 1) // E{lcd.setCursor(0, 0); // Move cursor up to the top line/rowlcd.write(byte(0));lcd.write(byte(1));lcd.setCursor(0, 1); // Move cursor down to the bottom line/rowlcd.write(byte(0));lcd.write(byte(1));}if(textflow >= 2) // EX{lcd.setCursor(2, 0);lcd.write(byte(2));lcd.write(byte(3));lcd.setCursor(2, 1);lcd.write(byte(3));lcd.write(byte(2));}if(textflow >= 3) // EX I{lcd.setCursor(4, 0);lcd.write(byte(4));lcd.setCursor(4, 1);lcd.write(byte(4));}if(textflow >= 4) // EXI L{lcd.setCursor(5, 0);lcd.write(byte(4));lcd.setCursor(5, 1);lcd.write(byte(5));lcd.write(byte(6));}if(textflow >= 5) // EXIL E{lcd.setCursor(7, 0);lcd.write(byte(0));lcd.write(byte(1));lcd.setCursor(7, 1);lcd.write(byte(0));lcd.write(byte(1));}if(textflow >= 6) // EXILE F{lcd.setCursor(9, 0);lcd.write(byte(4));lcd.write(byte(1));lcd.setCursor(9, 1);lcd.write(byte(4));lcd.write(byte(7));}if(textflow >= 7) // EXILEF O{lcd.setCursor(11, 0);lcd.write(byte(3));lcd.write(byte(2));lcd.setCursor(11, 1);lcd.write(byte(2));lcd.write(byte(3));}if(textflow >= 8) // EXILEFO X{lcd.setCursor(13, 0);lcd.write(byte(2));lcd.write(byte(3));lcd.setCursor(13, 1);lcd.write(byte(3));lcd.write(byte(2));}// EXILEFOX}}