
11
NonBlockingWrite.ino example
In the original example NonBlockingWrite code, change line 48
if (
!
SD.
begin
()) {
to
if (
!
SD.
begin
(
4
)) {
Also, add following lines after line 84:
// print the buffer length. This will change depending on when
// data is actually written to the SD card file:
Serial
.
(
"Unsaved data buffer length (in bytes): "
)
;
Serial
.
println
(
buffer.
length
())
;
// note the time that the last line was added to the string
The complete code should be as follows:
1.
/*
2.
Non-blocking Write
3.
4.
This example demonstrates how to perform non-blocking writes
5.
to a file on a SD card. The file will contain the current millis()
6.
value every 10ms. If the SD card is busy, the data will be buffered
7.
in order to not block the sketch.
8.
9.
NOTE: myFile.availableForWrite() will automatically sync the
10.
file contents as needed. You may lose some unsynced data
11.
still if myFile.sync() or myFile.close() is not called.
12.
13.
The circuit:
14.
SD card attached to SPI bus as follows:
15.
MOSI - pin 11
16.
MISO - pin 12
17.
SCK / CLK - pin 13
18.
CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
19.
20.
This example code is in the public domain.
21.
*/
22.
23.
#include <SD.h>
24.
25.
// file name to use for writing
26.
const
char
filename
[]
=
"demo.txt"
;
27.
28.
// File object to represent file
29.
File txtFile
;
30.
31.
// string to buffer output
Содержание WPI304N
Страница 1: ...MANUAL EN microSD Card Logging Shield for Arduino WPI304N whadda com ...
Страница 5: ...5 Circuit Diagram ...