//analog read info
int readAnalogPin1=A1;
int readAnalogVal1;
int dt=5;
float PotV1;
int solState2 = A2;
int sol2Hi;
float solV1;
#include <SD.h>
#include <SPI.h>
File myFile;
int pinCS = 10; // Pin 10 on Arduino Uno
void setup() {
Serial.begin(9600);
pinMode(pinCS, OUTPUT);
pinMode(solState2, INPUT);
// SD Card Initialization
if (SD.begin())
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}
// Create/Open file
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.println("Writing to file...");
// Write to file
myFile.println("Testing text 1, 2 ,3...");
myFile.close(); // close the file
Serial.println("Done.");
}
// if the file didn't open, print an error:
else {
Serial.println("error opening test.txt");
}
// Reading the file
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("Read:");
// Reading the whole file
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
}
else {
Serial.println("error opening test.txt");
}
}
void loop() {
// put your main code here, to run repeatedly:
sol2Hi=digitalRead(solState2);
solV1=sol2Hi;
readAnalogVal1=analogRead(readAnalogPin1);
PotV1=(5./1023.)*readAnalogVal1;
Serial.print(PotV1);
Serial.print(", ");
Serial.println (solV1);
delay(dt);
}