/*
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 10
*/
#include <SD.h>
//#include <Base64.h>
const int chipSelect = 10;
File vixlog;
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(10, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
if (SD.exists("vixlog.txt"))
{
Serial.print("Deleting old vixlog.txt file...");
SD.remove("vixlog.txt");
Serial.println("finished.");
}
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
Serial.print("Creating new vixlog.txt file...");
vixlog = SD.open("vixlog.txt", FILE_WRITE);
vixlog.println("vixlog file initialized.");
Serial.println("vixlog file initialized.");
if (SD.exists("1.vix"))
{
vixlog.println("1.vix file found. Decoding...");
Serial.println("1.vix file found. Decoding...");
}
else
{
vixlog.println("ERROR - 1.vix - File not found.");
vixlog.println("Ensure that the first vixen file you wish to play is named 1.vix");
vixlog.println("Exiting...");
Serial.println("ERROR - 1.vix - File not found.");
Serial.println("Ensure that the first vixen file you wish to play is named 1.vix");
Serial.println("Exiting...");
vixlog.flush();
vixlog.close();
return;
}
vixlog.flush();
vixlog.close();
File vixen1 = SD.open("1.vix", FILE_READ);
Serial.println("1.vix opened... ");
if (vixen1)
{
//note to self: Add 3
vixen1.seek(102);
while (vixen1.available())
{
Serial.write(vixen1.read());
}
Serial.println("end");
//vixen1.seek(i);
}
//Conversion code goes here
// vixlog.flush();
//vixlog.close();
vixen1.close();
}
void loop()
{
}