I have been reading and playing around. I am not totally lost...lol... almost but still.
So here is what I have so far. A lot of it was copied and pasted from examples, but there are a few things I have typed in.
#define DS1307_I2C_ADDRESS 0x68
#include "Wire.h"
#include <LiquidCrystal.h>
int blue = 3;
int white = 11;
int bluemin = 0;
int whitemin = 0;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
void setDateDs1307(byte second,
byte minute,
byte hour,
byte dayOfWeek,
byte dayOfMonth,
byte month,
byte year)
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.write(decToBcd(second));
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(dayOfWeek));
Wire.write(decToBcd(dayOfMonth));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.endTransmission();
}
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.read());
*dayOfMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}
void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
second = 56;
minute = 16;
hour = 18;
dayOfWeek = 6;
dayOfMonth = 12;
month = 5;
year = 18;
analogWrite(blue,bluemin);
analogWrite(white,whitemin);
lcd.begin(16,2);
lcd.setCursor(0,1);
lcd.print("blue:");
lcd.print(bluemin);
lcd.setCursor(8,1);
lcd.print("white:");
lcd.print(whitemin);
}
void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
int time = ((hour * 60) + minute);
map(time, 0, 1440, 0, 255);
}
So now I am trying to figure out how to get the PWM output accomplished. In the end the pwm output of the Arduino is going to be bumped up to 0-10v pwm. I am wanting to control two separate channels. The other thing I am going to have to figure out is the fact that I don't want either channel running at 100%. for instance channel one I want to ramp from 0 to 40% and channel 2 0 to 10%.
here is how I am thinking of doing the next part. There is something wrong with the formatting of my nested statements. and my brain is hurting. But before I go any further I would love some opinions. Thanks!
map(time, 0, 1440, 0, 255);
if (time >= 480 && time <720);
{
for (int i=0; i<=255; i++)
{
analogWrite(bluemin, i);
}
else if (time >=720 && time <900);
{
analogWrite(bluemin, 255);
}
else if (time >=900 && time <1320);
for (int i=0; i>=255; i--)
{
analogWrite(bluemin, i);
}
else (time >=1320 || time <480);
{
analogWrite(bluemin, 0);
}
}