GMU:Speculative Atmospheres II/Sophia Amelia Eickhoff: Difference between revisions

From Medien Wiki
mNo edit summary
mNo edit summary
Line 36: Line 36:
   Serial.begin(9600); //starting comunication with arduino
   Serial.begin(9600); //starting comunication with arduino
   while (!Serial) {
   while (!Serial) {
;  
  ;  
}
  }
   Serial.print("Initializing SD card..."); //initializing the SD card
   Serial.print("Initializing SD card..."); //initializing the SD card
   if (!SD.begin(10)) {
   if (!SD.begin(10)) {
   Serial.println("initialization failed!"); // signal if connection failed
   Serial.println("initialization failed!"); // signal if connection failed
   while (1);
   while (1);
}
  }
   Serial.println("initialization done."); // signal if connection succeded
   Serial.println("initialization done."); // signal if connection succeded
   myFile = SD.open("test.txt", FILE_WRITE); //naming file
   myFile = SD.open("test.txt", FILE_WRITE); //naming file
Line 50: Line 50:
   myFile.close();
   myFile.close();
   Serial.println("done.");
   Serial.println("done.");
}
  }
   else {
   else {
   // if the file didn't open, print an error:
   // if the file didn't open, print an error:
   Serial.println("error opening test.txt"); //signal if opening failed
   Serial.println("error opening test.txt"); //signal if opening failed
}
  }
}
  }
   void loop() {
   void loop() {
    
    
Line 77: Line 77:
   myFile.print( "Gas: ");
   myFile.print( "Gas: ");
   myFile.println(gas, DEC);
   myFile.println(gas, DEC);
//pulse
  //pulse
   int pulse = analogRead(A2);
   int pulse = analogRead(A2);
   myFile.print( "Pulse: ");
   myFile.print( "Pulse: ");
   myFile.println(pulse);
   myFile.println(pulse);
   delay(60000); //collect data every minute
   delay(60000); //collect data every minute
// close the file:
  // close the file:
   myFile.close();
   myFile.close();
   Serial.println("Sensor.geschrieben.");
   Serial.println("Sensor.geschrieben.");
}
  }
   else {
   else {
// if the file didn't open, print an error:
  // if the file didn't open, print an error:
   Serial.println("error opening test.txt");
   Serial.println("error opening test.txt");
}
  }
}
  }


''Breadboard''
''Breadboard''