1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include <SPI.h>
- #include "SdFat.h"
- #include "sdios.h"
- const uint8_t chipSelect = SS;
- SdFat sd;
- ArduinoOutStream cout(Serial);
- #define error(s) sd.errorHalt(F(s))
- void setup() {
-
- char name[] = "append.txt";
- Serial.begin(9600);
-
- while (!Serial) {
- yield();
- }
-
- cout << endl << F("Type any character to start\n");
- while (!Serial.available()) {
- yield();
- }
-
-
- if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {
- sd.initErrorHalt();
- }
- cout << F("Appending to: ") << name;
- for (uint8_t i = 0; i < 100; i++) {
-
- ofstream sdout(name, ios::out | ios::app);
- if (!sdout) {
- error("open failed");
- }
-
- for (uint8_t j = 0; j < 100; j++) {
-
- sdout << "line " << int(j) << " of pass " << int(i);
- sdout << " millis = " << millis() << endl;
- }
-
- sdout.close();
- if (!sdout) {
- error("append data failed");
- }
-
- if (i % 25 == 0) {
- cout << endl;
- }
- cout << '.';
- }
- cout << endl << "Done" << endl;
- }
- void loop() {}
|