I have my LCD working just fine with my Arduino Uno, but when I initialize the SD library via SD.begin() or even just hook up my SD card reader (Seeedstudio SD card shield v2.1) wired via a breadboard rather then plugging in directly so I can use the SPI pins for both then the LCD stops working. It does not matter if the LCD is initialized before or after the SD card.
Trying to initialize the SD library with the SD card connected and with or without the LCD connected also fails. I'm using the hardware SPI pins (11-13) and a level shifter for those signals. Note, that I've modified the PCD8544 library to use 13 = SCLK, 12 = MISO, 11 = MOSI and 9 = SPI select (10 is SD select).
Basically my problems boil down to:
- I can't initialize the SD card library
- I can't use the LCD with the SD card
Anyways, I've double & triple checked my wiring and everything seems ok. Just lost as how to debug this further.
Also, if anyone can suggest a good app for creating wiring diagrams for a Mac that would be great. I realize it's hard to debug this without seeing how things are wired up.
Thanks!
#include <VirtualWire.h>
#include <PCD8544.h>
#include <Wire.h>
#include <RTClib.h>
#include <SD.h>
uint8_t debug = 0;
#undef int
#undef abs
#undef double
#undef float
#undef round
/* Define Digital PINS */
#define SPI_CLK 13 /* SPI CLK */
#define SPI_MISO 12 /* SPI MISO */
#define SPI_MOSI 11 /* SPI MOSI */
#define SD_SELECT 10 /* SD Card SPI Select */
#define LCD_SELECT 9 /* LCD SPI Select */
#define LCD_DC 8 /* LCD data/command */
#define LCD_RESET 7 /* LCD Reset */
#define LED_PIN 6 /* LED Status */
#define RX_PIN 5 /* RF315Mhz RX */
/*
* DS1307 pins:
* RTC_SCL = Analog 5 I2C
* RTC_SDA = Analog 4 I2C
*/
#define GMTOFFSET -8 * 60 * 60 /* PST is GMT-8 */
#define RF_BAUD 600
#define DELAY 2750
PCD8544 LCD;
RTC_DS1307 RTC;
unsigned long missed = 0;
unsigned long received = 0;
uint8_t temp_mask = 0;
unsigned long mstimer;
int t1 = 0;
int t2 = 0;
int t3 = 0;
int t4 = 0;
void setup() {
pinMode(LED_PIN, OUTPUT);
/* USB Serial */
Serial.begin(9600);
/* I2C & RTC Setup */
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
}
// following line sets the RTC to the date & time this sketch was compiled
// RTC.adjust(DateTime(__DATE__, __TIME__));
/* Wireless receiver */
Serial.println("Starting receiver!");
vw_set_ptt_inverted(true);
vw_set_rx_pin(RX_PIN);
vw_setup(RF_BAUD);
vw_rx_start();
pinMode(LCD_SELECT, OUTPUT);
pinMode(SD_SELECT, OUTPUT);
/* initialize LCD */
LCD.begin_custpins(84, 48, SPI_CLK, SPI_MOSI, LCD_DC,
LCD_RESET, LCD_SELECT);
/* initialize SD Card on SPI Bus */
if (!SD.begin(SD_SELECT)) {
Serial.println("SD card initialize failed, or not present");
} else {
Serial.println("SD card initialize success!");
}
delay(3000);
}