3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

LCD Shifter for Arduino

LCD Shifter for Arduino
The original idea was to create a library that simplify the use of IC 74HC595 between Arduino and other hardware. In this Instructable I will share this to you using as example the control of a 16x2 LCD.
The example will show on the LCD the seconds that has passed since Arduino was restarted.

I hope it will be useful to you.

What do you need for THIS example?
- Arduino
- Arduino IDE installed
- LCD
- One IC 74HC595
- One 4.7Kohm resistor or similar
- One "104" capacitor
- Wires!

 
Remove these adsRemove these ads by Signing Up
 

Step 1Place the Library under Arduino Folder

I've named the library "ShiftOut". It goes under %arduino-directory%/hardware/libraries

This one is the library that I've programmed. Comments are welcome.

« Previous StepDownload PDFView All StepsNext Step »
54 comments
1-40 of 54next »
Mar 12, 2012. 8:34 AMStruggler says:
Hi,
Having problems compiling this script example.
I might have missed something vital?
Have the libraries saved in the location specified.
Using Arduino UNO R3 and 1.0 IDE

Here are the error messages...
Its probably something simple on my part but can't work out what it is.

Any help appreciated.

Thanks
Struggler

C:\arduino-1.0\libraries\Lcd\Lcd.cpp:26:27: error: WConstants.h: No such file or directory
C:\arduino-1.0\libraries\Lcd\Lcd.cpp: In member function 'void Lcd::send(uint8_t, uint8_t)':
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:65: error: 'delay' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp: In member function 'void Lcd::set_enable(uint8_t)':
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:113: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp: In member function 'void Lcd::pulse_enable()':
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:119: error: 'HIGH' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:120: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:121: error: 'LOW' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp: In member function 'void Lcd::check_bf()':
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:131: error: 'INPUT' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:136: error: 'HIGH' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:137: error: 'digitalRead' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:138: error: 'LOW' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:148: error: 'OUTPUT' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp: In member function 'void Lcd::setup()':
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:174: error: 'OUTPUT' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:180: error: 'OUTPUT' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:186: error: 'delay' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:195: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:206: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp: In member function 'void Lcd::dWrite(uint8_t, uint8_t)':
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:348: error: 'digitalWrite' was not declared in this scope
C:\arduino-1.0\libraries\Lcd\Lcd.cpp: In member function 'void Lcd::pMode(uint8_t, uint8_t)':
C:\arduino-1.0\libraries\Lcd\Lcd.cpp:355: error: 'pinMode' was not declared in this scope
Mar 2, 2012. 1:54 AMDominion-Network says:
Thanks to your instructable (This one) I've managed to follow it to the letter and I've produced this.

Thank you
Jan 27, 2012. 7:13 PMmarker4455 says:
The Code provided up above gives me an error, while compiling/verifying. Please Help.
Jan 27, 2012. 7:14 PMmarker4455 says:
I meant in Step 3, of this tutorial.
Jan 1, 2012. 7:51 AMagodinhost says:
I've Forgot to mention that I'm using arduino 0022.
Jan 1, 2012. 7:46 AMagodinhost says:
I've built a simple header for this project and everything seems to be fine, it works perfect. However, when using ONLY the 5v power supply, it don't work out - in this case the arduino is not connected to the PC. I saw your comment about the initialization bug in the original liquid crystal library and I'm wondering if it's not the cause of this issue ...

Please?
Dec 23, 2011. 10:06 AMDominion-Network says:
Just wondering if you could do a more advanced version of this tutorial, say for example hooking up a keypad to the LCD display.
Aug 6, 2011. 9:50 AMmsanchez16 says:
Hello, please correct the first line
wich says: #include < Lcd.h>;
must says: #include WITHOUT THE SPACE :)

Thanks for your work

sorry for my english
Nov 24, 2011. 2:29 PMDominion-Network says:
I'm trying to follow this instructable, but you've forgotten to list the wire diagram, what pin connects to what wire on the LCD screen?

I would love to include this in a huge project I currently have planned, but without the pin layout I will have to guess at it.
Nov 25, 2011. 12:58 AMDominion-Network says:
I managed to get it to work, thanks for taking the time and effort to help me, when I do my big project I'll acknowledge you in the credits
May 3, 2010. 10:25 AMrobot797 says:
is it posible to use custem characters with this librarie
cus i cant get it to work....
May 3, 2010. 12:02 PMrobot797 says:
i just found out how to do that
example code below

but now a new problem accurs
when i use the funktion "FUNCTION_2LINE"
the tekst becomes fage and vaded
how to fix it



/*
 * Define custom characters for creating an animation
 */
#include <Lcd.h>
#include <ShiftOut.h>


ShiftOut sOut(8,12,11,2);

Lcd lcd = Lcd(16, FUNCTION_4BIT, &sOut);

int potPin = 0;    // select the input pin for the potentiometer
int val = 100;       // variable to store the value coming from the sensor
                            //set to 100 for when there

uint8_t smile[] = {0x00,0x0A,0x00,0x11,0x0E,0x00,0x00,0x00};
uint8_t stripe[] = {0x13,0x06,0x0C,0x19,0x13,0x06,0x0C,0x19};
uint8_t stripe1[] = {0x19,0x13,0x06,0x0C,0x19,0x13,0x06,0x0C};
uint8_t stripe2[] = {0x0C,0x19,0x13,0x06,0x0C,0x19,0x13,0x06};
uint8_t stripe3[] = {0x06,0x0C,0x19,0x13,0x06,0x0C,0x19,0x13};

 


void setup()
{
 

  // set pin assignment
  lcd.set_ctrl_pins(CTRLPINS(1,2,3)); // RS->1, RW->2, E->3
  lcd.set_data_pins(_4PINS(4,5,6,7)); // D4->4, D5->5, D6->6, D7->7
 
  lcd.setup(); // setup arduino and initialize LCD
    lcd.clear();
  // define the custom characters
  lcd.define_char(0, smile);
  lcd.define_char(1, stripe);
    lcd.define_char(2, stripe1);
      lcd.define_char(3, stripe2);
        lcd.define_char(4, stripe3);


}

void loop()
{
  val = analogRead(potPin);
  lcd.home();
  lcd.print((char)1);   
  delay(val);
  lcd.clear();
    lcd.print((char)2); 
      delay(val);
  lcd.clear();
      lcd.print((char)3);
      delay(val);
  lcd.clear();
      lcd.print((char)4);
      delay(val);
  lcd.clear();

}

Apr 18, 2010. 10:59 AMrobot797 says:
i feel like 2 things a nerd and a idiot

how do i put tekst on the second line?
Apr 19, 2010. 8:01 AMrobot797 says:
never mind found it out

lcd.move_to(0, 2);

that is the code

lcd.move_to(0 collum , 2 row);
Feb 13, 2010. 4:10 AMLenny24 says:
Hi.

Im Living in Germany and I cant find an 74HC595.
Could i use your ShiftOut Library with a 4014?
Its' an 8-Bit Shift Register,too. I Think the Connection-Layout is a Little bit different.


Apr 18, 2010. 11:47 AMrobot797 says:
order a few in holland or on ebay

i found some that work

and it is like 50 km over the german border
Feb 14, 2010. 12:40 AMLenny24 says:
The Pin Layout isnt the same.

http://www2.produktinfo.conrad.com/datenblaetter/150000-174999/172707-da-01-en-MC_14014_CD_4014_MC_14021_CD4021.pdf
Feb 14, 2010. 10:09 AMLenny24 says:
Thanks.
Feb 13, 2010. 7:52 AMno0x says:
I don't know but on Ebay you could find 10 pcs of 74HC595 for about 3 USD (2,2 €) fdp in
Feb 13, 2010. 8:54 AMLenny24 says:
Thanks.
Apr 2, 2010. 6:51 PMNXTreme says:
Just a word of warning. Lots of times the electronic parts on eBay come from China or something and actually aren't what they advertise. Here's a link that sort of explains what I'm saying. Dangerous Fakes

Even the Chumby had problems.
Apr 12, 2010. 2:11 PMrobot797 says:
i have 2 questions

1: what is the type of lcd you use
3:what happened to 2
4:could a second 74HC595 be added to drive led

so i mean a lcd and 4 or 7 leds?
Apr 12, 2010. 8:42 PMrobot797 says:
so when i conect a second 595 on the way like this
http://www.arduino.cc/en/Tutorial/ShiftOut

then i could program some leds in it

that would be cool
i am building the starting chip for a turbine engine

but the data panel (it shows if evrything is working) would have 10 cables if you did not show me your way 

thank you
Apr 18, 2010. 10:08 AMrobot797 says:

i made a small script that uses an lcd- 1 button-4 led's-2 595's
and here is it's script

#include <Lcd.h>
#include <ShiftOut.h>
#include "Servo.h"

Servo gasservo;

ShiftOut sOut(8,12,11,2);
Lcd lcd = Lcd(16, FUNCTION_4BIT | FUNCTION_2LINE | FUNCTION_5x11, &sOut);

int switchPin = 4;              // switch is connected to pin 2

 

int val;                        // variable for reading the pin status
int val2;                       // variable for reading the delayed status
int buttonState;                // variable to hold the button state

int lightMode = 0;              // What mode is the light in?

void setup() {
  pinMode(switchPin, INPUT);    // Set the switch pin as input
    lcd.set_ctrl_pins(CTRLPINS(1,2,3)); // RS->1, RW->2, E->3
  lcd.set_data_pins(_4PINS(4,5,6,7)); // D4->4, D5->5, D6->6, D7->7
 
  lcd.setup();
 
  lcd.clear();
  gasservo.attach(5);
  Serial.begin(9600);           // Set up serial communication at 9600bps
  buttonState = digitalRead(switchPin);   // read the initial state
}

void loop(){
  val = digitalRead(switchPin);      // read input value and store it in val
  delay(10);                         // 10 milliseconds is a good amount of time
  val2 = digitalRead(switchPin);     // read the input again to check for bounces
  if (val == val2) {                 // make sure we got 2 consistant readings!
    if (val != buttonState) {          // the button state has changed!
      if (val == LOW) {                // check if the button is pressed
        if (lightMode == 0) {          // if its off
          lightMode = 1;               // turn lights on!
        } else {
          if (lightMode == 1) {        // if its all-on
            lightMode = 2;             // make it blink!
          } else {
            if (lightMode == 2) {      // if its blinking
              lightMode = 3;           // make it wave!
            } else {
     if (lightMode == 3) { //  if its waving,
                lightMode = 0;           // turn light off!
              }
   }
          }
        }
      }
    }
    buttonState = val;                 // save the new state in our variable
  }

  // Now do whatever the lightMode indicates
  if (lightMode == 0) { // all-off
  lcd.clear();
  lcd.home();
  lcd.print("off");
    sOut.digitalWrt(9, LOW);
        sOut.digitalWrt(10, LOW);
            sOut.digitalWrt(11, LOW);
                sOut.digitalWrt(12, LOW);

  }

  if (lightMode == 1) { // all-on
  lcd.clear();
  lcd.home();
  lcd.print("on");
    sOut.digitalWrt(9, HIGH);
        sOut.digitalWrt(10, HIGH);
            sOut.digitalWrt(11, HIGH);
                sOut.digitalWrt(12, HIGH);
  }

  if (lightMode == 2) { // blinking
  lcd.clear();
    lcd.home();
  lcd.print("blink");
    sOut.digitalWrt(9, HIGH);
        sOut.digitalWrt(10, HIGH);
            sOut.digitalWrt(11, HIGH);
                sOut.digitalWrt(12, HIGH);
    delay(100);
    sOut.digitalWrt(9, LOW);
        sOut.digitalWrt(10, LOW);
            sOut.digitalWrt(11, LOW);
                sOut.digitalWrt(12, LOW);
    delay(100);
  }
  if (lightMode == 3)  { // "wave"
  lcd.clear();
      lcd.home();
  lcd.print("wave");
    sOut.digitalWrt(12, LOW);
    sOut.digitalWrt(9, HIGH);
    delay(50);
    sOut.digitalWrt(9, LOW);
    sOut.digitalWrt(10, HIGH);
    delay(50);
    sOut.digitalWrt(10, LOW);
    sOut.digitalWrt(11, HIGH);
    delay(50);
    sOut.digitalWrt(11, LOW);
    sOut.digitalWrt(12, HIGH);
    delay(50);
    sOut.digitalWrt(12, LOW);
  }   
}
 

Apr 18, 2010. 5:16 AMrobot797 says:
could you draw a normal diagram
i have an hard time decivering your diagrams now
1-40 of 54next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
2
Followers
1
Author:GusPS