아두이노 > Arduino's LiquidCrystal Library with SPI (74HC595 )

TODAY3,312 TOTAL4,689,387
사이트 이용안내
Login▼/회원가입
최신글보기 질문게시판 기술자료 동영상강좌

아두이노 센서 ATMEGA128 PWM LED 초음파 AVR 블루투스 LCD UART 모터 적외선


BASIC4MCU | 아두이노 | 아두이노 | Arduino's LiquidCrystal Library with SPI (74HC595 )

페이지 정보

작성자 키트 작성일2017-09-11 16:54 조회4,412회 댓글0건

본문

Arduino's LiquidCrystal Library with SPIAuthor: Juan Hernandez (juanh0238)


Navigation


Description

This is the same library that comes with Arduino I just added SPI functionality to use a Shift Register (I was using a 74HC595). it can be used with SPI or the same way it was intended with six or eight wires or whatever. all I did was to add a way for it to communicate with the LCD using SPI and a shift register other then that it is the exact same. I figured why write another library when there was one already written and free and fully functional and made public for the same purpose. will Linux had become what it is if people would have writen a diferent operating system for every project they had, or functionality they needed I think not. (that is a message for everyone) so here it is I hope it is of use. I also hope no one else has written it already and I just wasted my time, since I am new and learning it takes me longer than it would a seasoned programer, also as I mentioned above I don't like to reinvent the wheel unless the code is not readily available. it was good learning though.


Download, install and import

 This version only works in arduino versions before 1.0

Download here: LiquidCrystal.zip

 this version works on arduino 1.0 and the older versions

Download here: LiquidCrystal_1.zip

Breadboard Sketch: LCD_using_74HC595_and_SPI.png

and replace the LiquidCrystal folder in the libraries folder of your Arduino installation directory with this one.

You can see an example sketch from "File -> Examples -> LiquidCrystal -> HelloWorld_SPI".

To create a new sketch, select from the menubar "Sketch->Import Library->LiquidCrystal". Once the library is imported, an '#include <LiquidCrystal.h>' line will appear at the top of your Sketch. you will also need to include the SPI library. (in other words just as you would use the regular Library since its the same) the only diference is it takes only one parameter the sspin for SPI (or the latchPin of the register) if you want to use SPI otherwise it is used the same.


Creation

I'll just use the example that is in the Examples folder:

 

  1. #include
  2.  
  3. //some comments missing here but they will be in the original sketch
  4.  
  5. // include the library code:
  6. #include
  7.  
  8. // initialize the library with the number of the sspin
  9. //(or the latch pin of the 74HC595)
  10. LiquidCrystal lcd(10);
  11.  
  12. void setup() {
  13.   // set up the LCD's number of columns and rows:
  14.   lcd.begin(20, 4);
  15.   // Print a message to the LCD.
  16.   lcd.print("hello, world!");
  17. }
  18.  
  19. void loop() {
  20.   // set the cursor to column 0, line 1
  21.   // (note: line 1 is the second row, since counting begins with 0):
  22.   lcd.setCursor(0, 1);
  23.   // print the number of seconds since reset:
  24.   lcd.print(millis()/1000);
  25. }

 


Connections

The 74HC595 or the CD4094 shift register can be used. They operate in the same way, but they have different layouts and different names for the pins.

A clock signal is used for a serial input of 8 data-bits into a shift-register. The contents of the shift-register are copied into a latch with a strobe pulse. The outputs of the latch register is on the output pins.

Data = The data bits (74HC595 pin 14 "DS").
Clock = The shift clock for the data bits (74HC595 pin 11 "SHCP").
Latch = The strobe that copies the databits into the latch (74HC595 pin 12 "STCP").

Connect to SPI:
Data = MOSI = Arduino pin 11
Clock = SCK = Arduino pin 13
Latch = SS = Arduino pin 10, but also other pins can be used.


BreadBoard Ilustration


2093095301_GFP2RkLq_LCD_using_74HC595_and_SPI.png
Note:I had to connect pin 5 on the LCD to gnd (not on diagram) to make it work.


Using those 2 leftover pins Q0, Q2

I've found a workaround with the library.

Modify the LiquidCrystal.h by making the _bitString variable and spiSendOut() functions public.

Code:

 

  1. public:
  2.   uint8_t _bitString;
  3.   void spiSendOut();

 

Then by setting the value of bitString and sending it you can set the register values; 1 = q0, 4=q2, 5=q0+q2

Code:

  1. lcd._bitString=VALUE;
  2. lcd.spiSendOut();

 

This is really useful of you don't want to waste those pins on your 74HC595!

Information about this page

Last Modified:December 01, 2014, at 11:27 AM
By:

http://playground.arduino.cc/Main/LiquidCrystal 

댓글 0

조회수 4,412

등록된 댓글이 없습니다.

아두이노HOME > 아두이노 > 전체 목록

게시물 검색

2022년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2021년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2020년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2019년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2018년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
Privacy Policy
MCU BASIC ⓒ 2020
모바일버전으로보기