Hello,
I have a TFT sheild, and I wanted to do an SD program but in all of the examples I can find, you need to name the d/c pin, but none are labeled d/c. It has the same layout and pins as this one,
http://www.smokeandwires.co.nz/blog/a-2-4-tft-touchscreen-shield-for-arduino/
but mine is mcufriend.
Could someone tell me which pin can substitute for the d/c pin, or if there is a way around using it.
eLion101:
Hello,
I have a TFT sheild, and I wanted to do an SD program but in all of the examples I can find, you need to name the d/c pin, but none are labeled d/c. It has the same layout and pins as this one,
http://www.smokeandwires.co.nz/blog/a-2-4-tft-touchscreen-shield-for-arduino/
but mine is mcufriend.
Could someone tell me which pin can substitute for the d/c pin, or if there is a way around using it.
It stands for Data/Command. It is sometimes called RS (Register Select).
Another question, I am using the example code, (now that it works)
// include the necessary libraries
#include <SD.h>
#include <SPI.h>
#include <TFT.h> // Hardware-specific library
// pin definition for the Uno
#define SD_CS 10
#define LCD_CS A3
#define DC A2
#define RESET A4
// pin definition for the Leonardo
// #define SD_CS 8
// #define LCD_CS 7
// #define DC 0
// #define RESET 1
TFT myScreen = TFT(LCD_CS, DC, RESET);
// this variable represents the image to be drawn on screen
PImage image;
void setup() {
// initialize the serial port
Serial.begin(9600);
while (!Serial) {
// wait for serial line to be ready
// needed for the Leonardo
}
// try to access the SD card
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS)) {
Serial.println("failed!");
return;
}
Serial.println("OK!");
// initialize and clear the GLCD screen
myScreen.begin();
myScreen.background(255, 255, 255);
// load the image from the SD card
image = myScreen.loadImage("cat.bmp");
// check if the image loaded properly
if (image.isValid() != true) {
Serial.println("error while loading cat.bmp");
}
//write the image on screen
myScreen.image(image, 0, 0);
}
void loop(){
// nothing happening here
}
But while running, this happens:
Initializing SD card...OK!
loadImage: file doesn't look like a BMP
error while loading cat.bmp
... But it is a .bmp file and when I check the properties it says "BMP file". Is there something wrong with the file?
Never mind, I got it working by converting it by save as in ms paint, not just save as from google images.