I am working on a school project to get a path to write to a text file, and get this error when I verify the code. Here is the complete code
#include <SPI.h>
#include <SD.h>
File myFile;
int coord[2][300];
void setup() {
// SD card check
Serial.begin(9600);
Serial.print("Initializing SD card...");
if (!SD.begin(4))
{
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
//Declarations
int n[300];
// open the file for reading:
myFile = SD.open("data.txt");
if (myFile)
{
Serial.println("data.txt:");
// read from the file and output int values to n array
/*
while (myFile.available())
{
arrayOfChars = myFile.read();
}
myFile.close();
for (int i=0; i<300; i++)
{
n[i] = atoi(arrayOfChars);
}
}
else{
Serial.println("error opening test.txt");
}
*/
/*
The coord array has 2 rows and 300 columns.
[1][i] is the x axis
[2][i] is the y axis
*/
//Finds size of array and building output code to text file
//int size = sizeof(n) / sizeof(int);
myFile = SD.open("map.txt", FILE_WRITE);
for (int i=300; i>0; i--) //i equals whatever the length of the array is
{
int x=1;
while (x<i)
{
myFile.print(" ");
x++;
}
if (round(coord[1][i]-coord[1][i-1]))= 0) //ERROR?
{
if (round(coord[2][i]-coord[2][i-1]) > 0)
{
up = round(coord[2][i]-coord[2][i-1]);
while (up >= 1)
{
myFile.println("|"); //not sure if this will be in the same line
up--;
}
elseif (round(coord[2][i]-coord[2][i-1]) < 0)
{
down = round(coord[2][i]-coord[2][i-1]);
while (down >= 1)
{
myFile.println(" "); //prints on the next line down
myFile.println("|");
down--;
}
}
else
{
//do nothing
}
}
if (round(coord[2][i]-coord[2][i-1]))== 0)
{
if (round(coord[1][i]-coord[1][i-1]) > 0)
{
right = round(coord[2][i]-coord[2][i-1]);
while (right >= 1)
{
myFile.print("_");
right--;
}
elseif (round(coord[1][i]-coord[1][i-1]) < 0)
{
left = round(coord[2][i]-coord[2][i-1]);
while (left >= 1)
{
myFile.print("_"); //not sure how to go back with the _ line
down--;
}
}
else
{
//do nothing
}
}
}
}
}