It's this line of code that throws the whole deal. I definitely did forget to identify pin 9 (fixed now). And I don't have a pot on it, but it still won't work anytime I include the following:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
I haven't tried with a pot (I will, when I'm back home, currently on military orders away from home station).
Any assistance much appreciated!
#include <Wire.h>
#include <LiquidCrystal.h>
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int ledPin = 9; // LED connected to digital pin 9
int clockAddress = 0x68; // This is the I2C address
int command = 0; // This is the command char, in ascii form, sent from the serial port
long previousMillis = 0; // will store last time Temp was updated
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
byte test;
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
// Gets the date and time from the ds1307 and prints result
void getDateDs1307() {
// Reset the register pointer
Wire.beginTransmission(clockAddress);
Wire.send(0x00);
Wire.endTransmission();
Wire.requestFrom(clockAddress, 7);
// A few of these need masks because certain bits are control bits
second = bcdToDec(Wire.receive() & 0x7f);
minute = bcdToDec(Wire.receive());
// Need to change this if 12 hour am/pm
hour = bcdToDec(Wire.receive() & 0x3f);
dayOfWeek = bcdToDec(Wire.receive());
dayOfMonth = bcdToDec(Wire.receive());
month = bcdToDec(Wire.receive());
year = bcdToDec(Wire.receive());
Serial.print(hour, DEC);
Serial.print(":");
Serial.print(minute, DEC);
Serial.print(":");
Serial.print(second, DEC);
Serial.print(" ");
Serial.print(month, DEC);
Serial.print("/");
Serial.print(dayOfMonth, DEC);
Serial.print("/");
Serial.println(year, DEC);
}
// Sample frequency in milliseconds
const double Freq = 500;
// This constant describes the rate pin. It won't change:
const int Rate = 1;
// How big a sample to take
const long SampleSize = 6682;
// Raw Data
// Array for collecting instantaneous rate data
// Indices
long Sample = 0; // Index for IRate and Four
long PrevMic = 1000000;
long disp;
int Trigger;
void setup()
{
// lcd.begin(16, 2);
// Initialize the serial communications:
pinMode(ledPin, OUTPUT); // sets the pin as output
analogWrite(ledPin, 75);
Wire.begin();
Serial.begin(9600);
delay(1000); //Wait a second for OpenLog to init
}
void loop()
{
Wire.beginTransmission(clockAddress);
Wire.send(0x00);
Wire.endTransmission();
Wire.requestFrom(clockAddress, 7);
// A few of these need masks because certain bits are control bits
second = bcdToDec(Wire.receive() & 0x7f);
minute = bcdToDec(Wire.receive());
// Need to change this if 12 hour am/pm
hour = bcdToDec(Wire.receive() & 0x3f);
dayOfWeek = bcdToDec(Wire.receive());
dayOfMonth = bcdToDec(Wire.receive());
month = bcdToDec(Wire.receive());
year = bcdToDec(Wire.receive());
Trigger = 0;
if ((Trigger == 0)&&(hour < 30))
{
Sample = 0;
getDateDs1307();
do
{
Serial.print(analogRead(Rate));
delay(Freq); // Delay for proper DFT sample rate
Serial.print(" ");
disp = micros() - PrevMic;
Serial.print(disp);
PrevMic = disp + PrevMic;
Sample++; // Increase index
Serial.println();
} while (Sample < SampleSize); // SampleSize Sample set
getDateDs1307();
}
}