 File log_file;
 
 void print_log() {
+
+  log_file = SD.open("log.csv", FILE_WRITE);
 
   print(gps.location.lat(), 6);
   print(',');

// GPS
#include <SoftwareSerial.h>
#include "TinyGPSPlus/TinyGPS++.h"
#define GPS_RX           9 // Arduino RX pin connected to GPS TX
#define GPS_TX           8 // Arduino TX pin connected to GPS RX
#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>
#include <SPI.h>
#define SD_PIN 10

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

  print(',');
  print(map(WIND, 0, 1023 , 0, 100)); // meter per second
  println();

  log_file.close();
}

void setup() {

  Serial.begin(9600);
  gps_port.begin(GPS_BAUD_RATE); //GPS Setup

  //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() {

  delay(500);

  // update GPS
  while(gps_port.available()) gps.encode(gps_port.read());
