Yeah, there were several extra!! I haven't tested this, but it compiles fine.
Part 1:
// AQUATROLLER //
//***************************Arduino Initialisation***********************************
#include <LiquidCrystal.h>
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68
#define led_white_pin 5 // Output to white leds on pwm pin 5
#define alarmpin 4 // Output to alarm circuit on digital pin 4
#define led_actinic_pin 3 // Output to actinic leds on pwm pin 3
#define fuge_light_pin 2 // Output to fuge light on digital pin 2
LiquidCrystal lcd(11, 13, 12, 7, 8, 9, 10);
int water_temp_sensor = 3; // Water Temp Sensor connects to Pin 2
int water_temp_c = 0,water_temp_f = 0; // Water temperature variables
int samples[8]; // Water temperature variables to make a better precision
int maxi = -100,mini = 100; // Water integers to start max/min water temperature
int i;
int ph_sensor = 4; // Ph sensor connects to pin 4
int HS_value = 0; // Lights Heat SInk Variable
int HS_lm35pin = 2; // Lights heat Sink Temp sensor on analog pin 2
int HS_fanpin = 6; // Output to Heat Sink Fans on pwm pin 6
int value1 = 0;
int value2 = 0;
int value3 = 255;
int value4 = 255;
long time1 = 0;
long time2 = 0;
long time3 = 0;
long time4 = 0;
unsigned long last_temperature_check_time = 0; // Time Delay Routine Setup
unsigned long last_lcd_turn_on_time = 0; //
//*************************RTC Intialisation*******************************************
// 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) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour)); // If you want 12 hour am/pm you need to set
// bit 6 (also need to change readDateDs1307)
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
void setup()
{
//*******************************Setup Routine of RTC*************************************
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin(); // Starts 2 wire commuication with RTC module
Serial.begin(9600); // Starts Serial communication with PC
pinMode (HS_fanpin, OUTPUT); // Sets digital pin 6 as an output pin
pinMode (led_white_pin, OUTPUT); // Sets digital pin 5 as an output pin
pinMode (alarmpin, OUTPUT); // Sets digital pin 4 as an output pin
pinMode (led_white_pin, OUTPUT); // Sets digital pin 5 as an output pin
pinMode (led_actinic_pin, OUTPUT); // Sets digital pin 3 as an output pin
pinMode (fuge_light_pin, OUTPUT); // Sets digital pin 2 as an output pin
time1 = millis();
time2 = millis();
time3 = millis();
time4 = millis();
//*****************************************************************************************
//***************************SET TIME & DATE HERE******************************************
// **********Change these values to what you want to set your clock************************
// Remove (//) from front of..... setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
// Then set the time and date and upload to Arduino,
// Then place them back and save program
second = 40;
minute = 50;
hour = 15;
dayOfWeek = 2;
dayOfMonth = 10;
month = 2;
year = 9;
//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
//*****************************************************************************************
//*****************************************************************************************
}
void loop()
{
//*****************************Water Temp Time Delay Routine***************************************
unsigned long time = millis();
if (time - last_temperature_check_time > 5000) // Has it been 5 seconds?
{
last_temperature_check_time = time;
//************************Main Temp Read and Display Routine*********************************//
lcd.clear(); // Clears LCD screen
lcd.print("..AQUATROLLER.."); // Displays AQAUTOLLER on top line
lcd.setCursor(9,5); // Positions cursor for TEMP: label
lcd.print("TEMP:"); // Displays TEMP:
lcd.setCursor(23,5); // Positions cursor for degrees label
lcd.print((char)223); // Displays degrees symbol
lcd.setCursor(24,5); // Positions cursor of F label
lcd.print("F"); // Displays F label
lcd.setCursor(16,1); // Positions cursor for Ph: label
lcd.print("Ph:"); // Displays Ph: label
lcd.setCursor(27,1); // Positions cursor for Ph reading
lcd.print("00"); // Displays Ph reading************** AJUST THIS PART FOR ACTUAL PH READIN WHEN SENSOR IS FITTED!!!!!!!!!!!!!!!
lcd.setCursor(30,1); // Positions cursor for ph reading label
lcd.print("Ph"); // Displays ph reading label
for(i = 0;i<=7;i++) // Gets 8 samples of temperature
{
samples[i] = ( 5.0 * analogRead(water_temp_sensor) * 100.0) / 1024.0;
water_temp_c = water_temp_c + samples[i];
}
water_temp_c = water_temp_c/8.0; // Better precision
water_temp_f = (water_temp_c * 9)/ 5 + 32; // Converts celcius to fahrenheit
if(water_temp_f > maxi) {maxi = water_temp_f;} // Set max temperature ( F )
if(water_temp_f < mini) {mini = water_temp_f;} // Set min temperature ( F )
lcd.setCursor(19,5); // Positions cursor to display WATER TEMP
lcd.print(water_temp_f,DEC); // Sends farenheit temp to screen
//*****************************Send Serial Temp Data to Computer**************************
Serial.print(water_temp_c,DEC);
Serial.print(" Celsius, ");
Serial.print(water_temp_f,DEC);
Serial.print(" fahrenheit -> ");
Serial.print(maxi,DEC);
Serial.print(" Max, ");
Serial.print(mini,DEC);
Serial.println(" Min ");
water_temp_c = 0;
}
//**************************LCD Print Routine of RTC***************************************
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
lcd.setCursor(0,1);
lcd.print(hour, DEC);
lcd.print(":");
lcd.print(minute, DEC);
lcd.print(" ");
lcd.print(month, DEC);
lcd.print("/");
lcd.print(dayOfMonth, DEC);
lcd.print("/");
lcd.print(year, DEC);