Guest User

Untitled

a guest
Jan 9th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <SD.h>
  3.  
  4. File Plik;
  5. int odczytanaWartosc = 0;
  6.  
  7. void setup()
  8. {
  9.   Serial.begin(9600);
  10.     while (!Serial)
  11.     {
  12.     ;
  13.   }
  14.   Serial.println("Wczytywanie karty SD");
  15.   if (!SD.begin(8)) {    
  16.     Serial.println("Wczytywanie zakończone niepowodzeniem!!");
  17.     return;  
  18.   }
  19.   Serial.println("Udało się! Karta wykryta!");
  20.  
  21. }
  22.  
  23. void loop()
  24. {
  25.   zapis();
  26.   odczytanaWartosc = analogRead(A1);  //Odczytujemy wartość napięcia
  27.   Serial.println(odczytanaWartosc);
  28. }
  29. void zapis()
  30. {
  31.   Plik = SD.open("test.txt", FILE_WRITE);
  32.   Plik.println(odczytanaWartosc);
  33.   Plik.close();
  34.   delay(300);
  35.   Serial.println("ZAPISANO!");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment