bonjour
voila pour continuer sur mon projet testeur j'ai acheté un module sd LCstudio
je modifie mon fichier SdFatConfig pour avoir les bonnes connexion
/** Software SPI Master Out Slave In pin /
uint8_t const SOFT_SPI_MOSI_PIN = 51;
/* Software SPI Master In Slave Out pin /
uint8_t const SOFT_SPI_MISO_PIN = 50;
/* Software SPI Clock pin */
uint8_t const SOFT_SPI_SCK_PIN = 52;
le test sdinfo est bon
si je test en ecriture et lecture avec ReadWrite ou ReadWriteSdFat je me retrouve avec des dossier et caractere ilisible sur ma SD
ATTENTION, les librairies SD (il y en a plusieurs) n'acceptent généralement que les noms au format 8.3 (huit caractères pour le nom + 3 pour une extension). Des noms trop longs peuvent entraîner des plantages.
Il ne faut pas oublier de fermer les fichiers ouverts.
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
//pinMode(10, OUTPUT);
if (!SD.begin(SD_CS_PIN)) {
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();
Serial.print("testing 1, 2, 3. ecriture");
Serial.println();
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
}
carte sd formaté et je control avec Sdinfo
voir sdinfo.txt
il ecrit bien sur la SD (monitor serie ReadWrite.txt)mais je me retrouve avec des fichiers inexploitable voir jpg
oui j'ai gardé la librairie SD et revue mes connections, mauvais contact
donc ça fonctionne je peu ecrire et lire
maintenant si je reprendmon post TESTEUR
j'ai deux varaible que je souhaite charger selon un choix dans la carte SD
je lit les fichier present sur la SD et je choisi
exemple
si choix 1selectionné
const char *nompoint[8] = {"J408","J407", "J406","J405", "J404","J403", "J402", "J401"};// nom des points inversés le N°0 ==N°9 de end
unsigned long motok[] = {0b110100000, 0b110100000, 0b001000000, 0b110100000, 0b000011000, 0b000011000, 0b000000110, 0b000000110}; // motif attendu
si choix 2 selectionné
const char *nompoint[8] = {"A","B", "C","D", "E","F", "G", "H"};// nom des points inversés le N°0 ==N°9 de end
unsigned long motok[] = {0b010100000, 0b010100000, 0b101000000, 0b010100000, 0b000011000, 0b000011000, 0b000001110, 0b000001110}; // motif attendu
etc......
je sais ecrire et charger du texte mais des variable comment faire
je cherche aussi à écrire dans un fichier sur carte SD. Je n'arrive pas à y écrire une structure de ma composition, il me bloque sur la fonction :
Fichier.write( Buffer, TailleBuffer) ;
Buffer est un uint8_t qui doit correspondre à une adresse si j'ai bien compris (celle du démarrage de la lecture des données à copier) et il me refuse le moyenne de passer l'adresse de ma structure. Qui connaît le truc ? Je pense que tu devrais soit avoir rapidement le même problème, soit avoir la solution !
#include <SD.h>
#define BrocheSD 10
#define MAX_C 3
struct Entete{
char Version[5] ;
unsigned long Score ;
word Coups ;
} ;
struct Plateau {
word Tableau [MAX_C+1][MAX_C+1] ;
} ;
struct TOUR{
unsigned long Score ;
word Coups ;
Plateau Tour ;
} ;
String n'est pas un tableau. C'est un objet.
Donc soit tu travailles avec une variable de type string
soit tu utilises la méthode toCharArray() sur l'objet MonF. Voir là: toCharArray() - Arduino Reference
Si tu n'as pas impérativement besoin d'utiliser un objet String la première solution est plus simple et moins gourmande en mémoire.