Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <SD.h>
  3. const int chipSelect = 4;
  4. void setup() {
  5. // Open serial communications and wait for port to open:
  6. Serial.begin(9600);
  7. while (!Serial) {
  8. ; // wait for serial port to connect. Needed for native USB port only
  9. }
  10.  
  11. Serial.print("Initializing SD card...");
  12. // see if the card is present and can be initialized:
  13. if (!SD.begin(chipSelect)) {
  14. Serial.println("Card failed, or not present");
  15. // don't do anything more:
  16. while (1);
  17. }
  18. Serial.println("card initialized.");
  19.  
  20. File dataFile = SD.open("datalog.txt");
  21.  
  22. if (dataFile) {
  23. while (dataFile.available()) {
  24. Serial.write(dataFile.read());
  25. }
  26. dataFile.close();
  27. } else {
  28. Serial.println("error opening datalog.txt");
  29. }
  30. }
  31.  
  32. void loop() {
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement