He probado alimentar los circuitos a parte y que la conexion de informacion se haga mediante Arduino, es decir, que los pines de 5V y GND de la placa no los utilizo. Os voy adjuntar el codigo haber si es problema de codigo pero no lo creo...
-
i++;*
-
}*
-
k = 0;*
//Serial.println("Escribiendo en el fichero...");
-
//while(inBuffer[k] != 42){*
-
myFile = SD.open("GPS1.CSV", FILE_WRITE); //{*
-
//Serial.println(inBuffer[k]); // write the GGA sentence*
-
//inBuffer[k]= p[k];*
-
//myFile.print(inBuffer[k]);*
-
if (strncmp(inBuffer, "$GPRMC",6) == 0)*
-
{*
-
Serial.print(inBuffer[k]);*
_ /*if(inBuffer[k]=='W')_
-
{*
-
Serial.println();*
_ }*/_
-
Serial.print(inBuffer[7]);*
-
Serial.print(inBuffer[8]);*
-
Serial.print(':');*
-
Serial.print(inBuffer[9]);*
-
Serial.print(inBuffer[10]);*
-
Serial.print(':');*
-
Serial.print(inBuffer[11]);*
-
Serial.print(inBuffer[12]);*
-
Serial.print(inBuffer[17]);*
-
Serial.print(inBuffer[20]);*
-
Serial.print(inBuffer[21]);*
-
Serial.print(inBuffer[22]);*
-
Serial.print(inBuffer[23]);*
-
Serial.print(inBuffer[24]);*
-
Serial.print(inBuffer[25]);*
-
Serial.print(inBuffer[26]);*
-
Serial.print(inBuffer[27]);*
-
Serial.print(inBuffer[28]);*
-
Serial.print(inBuffer[31]);*
-
Serial.print(inBuffer[32]);*
-
Serial.print(inBuffer[33]);*
-
Serial.print(inBuffer[34]);*
-
Serial.print(inBuffer[35]);*
-
Serial.print(inBuffer[36]);*
-
Serial.print(inBuffer[37]);*
-
Serial.print(inBuffer[38]);*
-
Serial.print(inBuffer[39]);*
-
Serial.println();*
-
myFile.print(inBuffer[7]);*
-
myFile.print(inBuffer[8]);*
-
myFile.print(':');*
-
myFile.print(inBuffer[9]);*
-
myFile.print(inBuffer[10]);*
-
myFile.print(':');*
-
myFile.print(inBuffer[11]);*
-
myFile.print(inBuffer[12]);*
-
myFile.print(inBuffer[17]);*
-
myFile.print(inBuffer[20]);*
-
myFile.print(inBuffer[21]);*
-
myFile.print(inBuffer[22]);*
-
myFile.print(inBuffer[23]);*
-
myFile.print(inBuffer[24]);*
-
myFile.print(inBuffer[25]);*
-
myFile.print(inBuffer[26]);*
-
myFile.print(inBuffer[27]);*
-
myFile.print(inBuffer[28]);*
-
myFile.print(inBuffer[31]);*
-
myFile.print(inBuffer[32]);*
-
myFile.print(inBuffer[33]);*
-
myFile.print(inBuffer[34]);*
-
myFile.print(inBuffer[35]);*
-
myFile.print(inBuffer[36]);*
-
myFile.print(inBuffer[37]);*
-
myFile.print(inBuffer[38]);*
-
myFile.print(inBuffer[39]);*
-
// myFile.print(inBuffer[40]);*
-
// myFile.print(inBuffer[41]);*
-
myFile.println();*
-
}*
myFile.close();
-
//Serial.println("done.");*
-
//}*
_ /*else {_
-
// if the file didn't open, print an error:*
-
Serial.println("error opening test.txt");*
_ }*/_
-
k++;*
-
// establish variables for duration of the ping,*
-
// and the distance result in inches and centimeters:*
-
long duration, inches, cm;*
-
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.*
-
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:*
-
pinMode(pingPin, OUTPUT);*
-
digitalWrite(pingPin, LOW);*
-
delayMicroseconds(2);*
-
digitalWrite(pingPin, HIGH);*
-
delayMicroseconds(5);*
-
digitalWrite(pingPin, LOW);*
-
// The same pin is used to read the signal from the PING))): a HIGH*
-
// pulse whose duration is the time (in microseconds) from the sending*
-
// of the ping to the reception of its echo off of an object.*
-
pinMode(pingPin, INPUT);*
-
duration = pulseIn(pingPin, HIGH);*
-
// convert the time into a distance*
-
inches = microsecondsToInches(duration);*
-
cm = microsecondsToCentimeters(duration);*
/*
-
Serial.print(inches);*
-
Serial.print("in, ");*
-
Serial.print(cm);*
-
Serial.print("cm");*
-
Serial.println();*
*/
-
delay(100);*
-
if(cm<=70)*
-
{*
// digitalWrite(13,HIGH);
-
myservo.write(130);*
-
delay(1000);*
-
long durationI, inchesI, cmI;*
-
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.*
-
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:*
-
pinMode(pingPin, OUTPUT);*
-
digitalWrite(pingPin, LOW);*
-
delayMicroseconds(2);*
-
digitalWrite(pingPin, HIGH);*
-
delayMicroseconds(5);*
-
digitalWrite(pingPin, LOW);*
-
// The same pin is used to read the signal from the PING))): a HIGH*
-
// pulse whose duration is the time (in microseconds) from the sending*
-
// of the ping to the reception of its echo off of an object.*
-
pinMode(pingPin, INPUT);*
-
durationI = pulseIn(pingPin, HIGH);*
-
// convert the time into a distance*
-
inchesI = microsecondsToInches(durationI);*
-
cmI = microsecondsToCentimeters(durationI);*
-
delay(100);*
-
//digitalWrite(13,LOW);*
-
myservo.write(30);*
-
delay(1000);*
-
long durationD, inchesD, cmD;*
-
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.*
-
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:*
-
pinMode(pingPin, OUTPUT);*
-
digitalWrite(pingPin, LOW);*
-
delayMicroseconds(2);*
-
digitalWrite(pingPin, HIGH);*
-
delayMicroseconds(5);*
-
digitalWrite(pingPin, LOW);*
-
// The same pin is used to read the signal from the PING))): a HIGH*
-
// pulse whose duration is the time (in microseconds) from the sending*
-
// of the ping to the reception of its echo off of an object.*
-
pinMode(pingPin, INPUT);*
-
durationD = pulseIn(pingPin, HIGH);*
-
// convert the time into a distance*
-
inchesD = microsecondsToInches(durationD);*
-
cmD = microsecondsToCentimeters(durationD);*
-
myservo.write(100);*
-
delay(1000);*
-
delay(100);*
-
if(cmI<cmD)*
-
{*
-
Serial.println("girar izquierda");*
-
myservo2.write(140);*
-
delay(1000);*
-
}*
-
if(cmI>=cmD)*
-
{*
-
Serial.println("girar derecha");*
-
digitalWrite(13,HIGH);*
-
myservo2.write(60);*
-
delay(1000);*
-
}*
-
}*
-
if(cm>=71)*
-
{*
-
//myservo.write(100);*
-
myservo2.write(100);*
-
digitalWrite(13,LOW);*
-
}*
-
}*
}
long microsecondsToInches(long microseconds)
{
-
// According to Parallax's datasheet for the PING))), there are*
-
// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per*
-
// second). This gives the distance travelled by the ping, outbound*
-
// and return, so we divide by 2 to get the distance of the obstacle.*
-
// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf*
-
return microseconds / 74 / 2;*
}
long microsecondsToCentimeters(long microseconds)
{
-
// The speed of sound is 340 m/s or 29 microseconds per centimeter.*
-
// The ping travels out and back, so to find the distance of the*
-
// object we take half of the distance travelled.*
-
return microseconds / 29 / 2;*
}