   print(',');
   print(map(WIND, 0, 1023 , 0, 100)); // meter per second
   println();
+
+  log_file.close();
 }
 
 void setup() {
 
-  #ifdef DEBUG
   Serial.begin(9600);
-  #endif
+  gps_port.begin(GPS_BAUD_RATE); //GPS Setup
 
-  gps.begin(GPS_BAUD_RATE); //GPS Setup
-  SD.begin(SD_PIN);         //SD card start
+  //SD card start
+  pinMode(SD_PIN, OUTPUT);
+  digitalWrite(SD_PIN, HIGH);
+  SD.begin(SD_PIN);
+//  if( !SD.begin(SD_PIN) ) Serial.println("ERROR: SD failure");
 }
 
 void loop() {
 
-  #ifdef DEBUG
-  delay(10);
-  #else
-  delay(5000);
-  log_file = SD.open("log.csv", FILE_WRITE);
-  #endif
+  delay(500);
 
   // update GPS
   while(gps_port.available()) gps.encode(gps_port.read());

File log_file;

void print_log() {

  print(gps.location.lat(), 6);
  print(',');

// GPS
#include <SoftwareSerial.h>
#include "TinyGPSPlus/TinyGPS++.h"
#define GPS_RX           9 // Arduino RX pin connected to GPS RX
#define GPS_TX           8 // Arduino TX pin connected to GPS TX
#define GPS_BAUD_RATE 9600 // The GPS Shield module defaults to 9600 baud
SoftwareSerial gps_port(GPS_TX, GPS_RX);
TinyGPSPlus gps;

// SD card
#include <SD.h>
#define SD_PIN 10

// code!
//#define DEBUG
#ifdef DEBUG
#define print   Serial.print
#define println Serial.println
