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 ads by
Signing UpStep 1Place the Library under Arduino Folder
This one is the library that I've programmed. Comments are welcome.
ShiftOut.zip3 KB| « Previous Step | Download PDFView All Steps | Next Step » |







































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
If "yes", maybe this instructions are not compatible with Arduino UNO R3. I remember to did this with Arduino 0015 or 0017. Try to use it instead.
Maybe other user can confirm if this works on Arduino UNO IDE.
I'll do the tests one of these days and tell you if it worked.
Thanks.
Thank you
Regards!...
Can you explain the problem with some more details?
Thanks.
Please?
wich says: #include < Lcd.h>;
must says: #include WITHOUT THE SPACE :)
Thanks for your work
sorry for my english
Thanks for telling....
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.
Let me know if that help you...
It's on the 4th step, 2nd image.
cus i cant get it to work....
I remember that the original lib can do that. Check www.slashdev.ca/arduino-lcd-library/
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();
}
how do i put tekst on the second line?
lcd.move_to(0, 2);
that is the code
lcd.move_to(0 collum , 2 row);
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.
i found some that work
and it is like 50 km over the german border
http://www2.produktinfo.conrad.com/datenblaetter/150000-174999/172707-da-01-en-MC_14014_CD_4014_MC_14021_CD4021.pdf
Alternatives are: MC54/74HC164, 74LS595 and CD4094.
Check the layout though.
Even the Chumby had problems.
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?
2) ?????
3) Yes, it will work. The main purpose was simplify the use of PINs beside a 595.
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
You'll have to adapt some code, but if u are a programmer will not have any problem.
You can see this video that is about connecting 2 595 in cascade and using the ShiftOut Library I made:
http://www.youtube.com/watch?v=dCAitY5223c
Here is the base code. It's not a reflect of the video, but it's a similar routine:
#include <ShiftOut.h>
ShiftOut Reg1(8,12,11,2);
void setup()
{
delay(1000);
}
void loop()
{
for (int j = 0; j < 16; j++)
{
Reg1.digitalWrt(j, HIGH);
delay(100);
Reg1.digitalWrt(j, LOW);
}
for (int j = 15; j >= 0; j--)
{
Reg1.digitalWrt(j, HIGH);
delay(100);
Reg1.digitalWrt(j, LOW);
}
}
I hope it's clear for you. If not, just let me know and I'll help you.
Regards.
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);
}
}
i have an hard time decivering your diagrams now