Am I missing some loop brackets? Please see line in green which is returning Expected unqualified-id before 'if'
//Based on Example by Tom Igoe
#include <SD.h>
#include "Wire.h"
#define DS1307_ADDRESS 0x68
//Set by default for the SD Card Library
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
//We always need to set the CS Pin
int CS_pin = 8;
int pow_pin = 8;
//IR Distance Sensor Pins
int IR1_pin = 0;
float refresh_rate = 0.0;
void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.println("Initializing Card");
//CS Pin is an output
pinMode(CS_pin, OUTPUT);
//Card will Draw Power from Pin 8, so set it high
pinMode(pow_pin, OUTPUT);
digitalWrite(pow_pin, HIGH);
//check if card is ready
if (!SD.begin(CS_pin))
{
Serial.println("Card Failure");
return;
}
Serial.println("Card Ready");
//Read the Configuration information (COMMANDS.txt)
File commandFile = SD.open("COMMANDS.txt");
if (commandFile)
{
Serial.println("Reading Command File");
float decade = pow(10, (commandFile.available() - 1));
while(commandFile.available())
{
float temp = (commandFile.read() - '0');
refresh_rate = temp*decade+refresh_rate;
decade = decade/10;
}
Serial.print("Refresh Rate = ");
Serial.print(refresh_rate);
Serial.println("ms");
}
else
{
Serial.println("Could not read command file.");
return;
}
}
void loop()
{printDate();
delay(1000);
}
byte bcdToDec(byte val) {
// Convert binary coded decimal to normal decimal numbers
return ( (val/16*10) + (val%16) );
}
void printDate(){
// Reset the register pointer
Wire.beginTransmission(DS1307_ADDRESS);
byte zero = 0x00;
Wire.write(zero);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
int second = bcdToDec(Wire.read());
int minute = bcdToDec(Wire.read());
int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
int monthDay = bcdToDec(Wire.read());
int month = bcdToDec(Wire.read());
int year = bcdToDec(Wire.read());
//print the date EG 3/1/11 23:59:59
Serial.print(month);
Serial.print("/");
Serial.print(monthDay);
Serial.print("/");
Serial.print(year);
Serial.print(" ");
Serial.print(hour);
Serial.print(":");
Serial.print(minute);
Serial.print(":");
Serial.println(second);
}
int value = analogRead(IR1_pin);
[color=green][font=Verdana] if (value > 375 || value < 300)[/font][/color]
{
Serial.println(value);
delay(500); //wait half a second, then check again.
//Open a file to write to
//Only one file can be open at a time
int IR1_val = Serial.println(value);
File logFile = SD.open("LOG.txt", FILE_WRITE | O_APPEND);
if (logFile)
{
logFile.println(analogRead(IR1_pin));
if (value > 375 || value < 300)
{
Serial.println(value);
delay(500);
logFile.close();
}
}
}}