I am playing for a while now with the TFT7735 and it does want i want till now.
Now I want to connect a seperate sd card to it ( because of the space i need not the built in) but I am not get it to work.
What i did :
connected to a UN0 using 1.8.5
TFT7735 :
SCK/CLK = pin 13
SDA/MOSI = pin 11
CS = pin 7 // Chip select control pin
DC / RS = pin 9 // Data Command control pin
RST = pin 8 // Reset pin (could connect to Arduino RESET pin)
libriary from bodmar
running sketch below and it is running oke.
#include <TFT_ST7735.h> // Hardware-specific library
TFT_ST7735 tft = TFT_ST7735(); // Invoke custom library
int x;
int y;
void setup(void) {
tft.init(); // initialize a ST7735S chip
tft.setRotation(1);
tft.fillScreen(ST7735_BLACK);
delay(1000);
}
void loop() {
tft.fillScreen(ST7735_BLACK);
uint8_t radius=5;
for (uint8_t radius=2; radius < tft.height()/2-5; radius=radius+2) {
tft.drawCircle(80, 64, radius, ST7735_GREEN);
delay(100);
}
}
Connect a sd card to the Arduino.
pinsetting :
GND = GND
VCC = 5v
MISO = 12(er staat moso op de kaart)
MOSI = 11
SCK = 13
CS = 4
When i run sketch belo, it is running without any problems and the tft screen is still connected.
(using the standard sd libriary)
/*
SD card read/write
This example shows how to read and write data to and from an SD card file
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// nothing happens after setup
}
When I want to use them both, i get the message "initialization failed! , using the sketch below
It looks that i have a kind of conflict but I how no clue how to solve it.
#include <TFT_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <SD.h>
File myFile;
TFT_ST7735 tft = TFT_ST7735(); // Invoke custom library
int x;
int y;
void setup(void) {
tft.init(); // initialize a ST7735S chip
tft.setRotation(1);
tft.fillScreen(ST7735_BLACK);
delay(1000);
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop() {
tft.fillScreen(ST7735_BLACK);
uint8_t radius=5;
for (uint8_t radius=2; radius < tft.height()/2-5; radius=radius+2) {
tft.drawCircle(80, 64, radius, ST7735_GREEN);
delay(100);
}
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
Could somebody help me out?