Pages: [1]   Go Down
Author Topic: interface both the SD CARD MODULE and LCD display to arduino ?  (Read 3123 times)
0 Members and 1 Guest are viewing this topic.
Colombo
Offline Offline
Newbie
*
Karma: 1
Posts: 36
Bachelor in EEE Student
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Friends,

First, I'm a newbie to arduino so any help is highly appreciated !  smiley

My project is a simple voltage / current monitor device with ACS 758 sensor . Basically the sensed voltage / current is to be shown in a 16x2 LCD . Also making a data log into a SD card is essential .

I tested the circuit with ONLY with the SD CARD MODULE and another time ONLY with the LCD MODULE . BOTH WORKED . But i haven't tried connecting both at same time as I have a problem .

So I have the LCD and SD CARD MODULE ; but my problem is both modules use the same pins ( pin 11, pin 12, pin 4 ) ?

Please help me to proceed .

Many Thanks,
Dileesha.



According to arduino site, the pin configuration for LCD is as below ,

 
Quote
* LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

LINK : http://arduino.cc/en/Tutorial/LiquidCrystal


According to SD CARD MODULE site, the pin configuration for SDCARD MODULE is as below ,

Quote
MODULE PINOUT:

PIN 1: GND    --->  Arduino GND
PIN 2: +3.3V  --->  Arduino 3V
PIN 3: +5V    --->  Arduino 5V
PIN 4: CS     --->  Arduino DIO 4
PIN 5: MOSI   --->  Arduino DIO 11
PIN 6: SCLK   --->  Arduino DIO 13
PIN 7: MISO   --->  Arduino DIO 12
PIN 8: GND    --->  N/A

You may copy, alter and reuse this code in any way you like but please leave
reference to HobbyComponents.com in your comments if you redistribute this code. */

LINK : http://www.hobbycomponents.com/index.php?route=product/product&filter_name=sd%20card&product_id=117
Logged

Dileesha Amarasena

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2176
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As the SD card needs the SPI, can you move the LCD to other pins, do you have a shield or wires?

I'm sure the LCD code can be modified to change the pins ( unless its SPI also ).

EDIT: Just had a look at the LiquidCrystal library, the pins are set in the constructor so it should be an easy fix if you have spare pins ( and aren't using a shield )

You only need to change pins 4, 11, and 12 according to your pinout lists.
« Last Edit: April 18, 2013, 09:16:05 pm by pYro_65 » Logged


Colombo
Offline Offline
Newbie
*
Karma: 1
Posts: 36
Bachelor in EEE Student
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@pYro_65

Many thanks for your idea sir .

First i must say, I'm using wires to connect the LCD to arduino ; and I use 4 bit mode . And it's a normal 16x2 LCD DISPLAY so I think it doesn't use that SPI thing.
( LMB162AFC / datasheet here http://www.datasheet.co.kr/datasheet-html/L/M/B/LMB162AFC-2_Shenzhen.pdf.html )

I'm a newbie to arduino and coding, could you please tell me how to edit the library file in the appropriate way ?

Quote
1. what file i should edit ? .h file or what ?
2. can i edit it using text editor or arduino IDE ?
3. should i only change the pins to some other pins ?

Thanks,
Dileesha.
Logged

Dileesha Amarasena

Colombo
Offline Offline
Newbie
*
Karma: 1
Posts: 36
Bachelor in EEE Student
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SOLVED !  smiley

It was really a simple edit I needed to do, but of course I figured that out after the explanation by @pYro_65 . So thank goes to him .

If there are newbies like me looking for help on this ; what i did was ,  smiley-grin

Quote
SD CARD MODULE USES below pins and I think we should not change them .

PIN 1: GND    --->  Arduino GND
PIN 2: +3.3V  --->  Arduino 3V
PIN 3: +5V    --->  Arduino 5V
PIN 4: CS     --->  Arduino DIO 4
PIN 5: MOSI   --->  Arduino DIO 11
PIN 6: SCLK   --->  Arduino DIO 13
PIN 7: MISO   --->  Arduino DIO 12
PIN 8: GND    --->  N/A

Quote
And the LCD uses below pins and what I did was I changed them .

* LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

PROBLEM WAS : both uses pin 4, pin 11, pin 12 same time .

SOLUTION : edit liquid crystal example in arduino IDE .

Quote
/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
  The circuit:
 * LCD RS pin to digital pin 12 //  smiley-wink change this to any digital pin you have left with no connection ; i used pin 8
 * LCD Enable pin to digital pin 11 //  smiley-wink change this to any digital pin you have left with no connection ; i used pin 7
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4 //  smiley-wink change this to any digital pin you have left with no connection ; i used pin 6
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //  smiley-wink then also change the " 12 " , " 11 " , " 4 " to the pin numbers you've given ; mine is(8, 7, 5, 6, 3, 2)

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

That's all . It worked !

Thanks,
Dileesha.
« Last Edit: April 19, 2013, 04:08:08 am by Dileesha » Logged

Dileesha Amarasena

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2176
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good post, Leaving the fix is nice. I'm sure someone will eventually find this thread looking for the same answer.
Logged


Pages: [1]   Go Up
Jump to: