Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <SD.h>
- const int chipSelect = 10;
- void setup() {
- Serial.begin(9600);
- Serial.print("Initializing SD card...");
- // see if the card is present and can be initialized:
- if (!SD.begin(chipSelect)) {
- Serial.println("Card failed, or not present");
- while (1);
- }
- Serial.println("card initialized.");
- }
- void loop() {
- // open the file. note that only one file can be open at a time,
- // so you have to close this one before opening another.
- File dataFile = SD.open("datalog3.txt", FILE_WRITE);
- // if the file is available, write to it:
- if (dataFile) {
- dataFile.print("Este arduino foi ligado a ");
- dataFile.print(millis()/1000);
- dataFile.println(" segundos");
- dataFile.close();
- // print serial port:
- Serial.print("Este arduino foi ligado a ");
- Serial.print(millis()/1000);
- Serial.println(" segundos");
- }else {
- Serial.println("error opening datalog.txt");
- }
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement