(im using spi but the problem occurs with simple electronics as well)
for some reason my arduino nano hates 3.3v and whenever I use it it freaks out, the arduino disconnects from the computer and wont revive new sketches and wont send data back to the pc along with that the entire arduino sketch freezes, I have a youtube link to what happens here odd arduino spi problems - YouTube
the wireing is is done according to this video
here is my sketch
#include <SD.h>
#include <SPI.h>
int CS_PIN = 10;
File file;
void setup()
{
Serial.begin(9600);
initializeSD();
createFile("test.txt");
writeToFile("This is sample text!");
closeFile();
openFile("prefs.txt");
Serial.println(readLine());
Serial.println(readLine());
closeFile();
}
void loop()
{
}
void initializeSD()
{
Serial.println("Initializing SD card...");
pinMode(CS_PIN, OUTPUT);
if (SD.begin())
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}
}
int createFile(char filename[])
{
file = SD.open(filename, FILE_WRITE);
if (file)
{
Serial.println("File created successfully.");
return 1;
} else
{
Serial.println("Error while creating file.");
return 0;
}
}
int writeToFile(char text[])
{
if (file)
{
file.println(text);
Serial.println("Writing to file: ");
Serial.println(text);
return 1;
} else
{
Serial.println("Couldn't write to file");
return 0;
}
}
void closeFile()
{
if (file)
{
file.close();
Serial.println("File closed");
}
}
int openFile(char filename[])
{
file = SD.open(filename);
if (file)
{
Serial.println("File opened with success!");
return 1;
} else
{
Serial.println("Error opening file...");
return 0;
}
}
String readLine()
{
String received = "";
char ch;
while (file.available())
{
ch = file.read();
if (ch == '\n')
{
return String(received);
}
else
{
received += ch;
}
}
return "";
}