Pages: [1]   Go Down
Author Topic: Programming Help  (Read 599 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am so new to this and I have a problem with this program. This code supposed to have two lines start at the same time, but some how only one starts and other wait till its finished before its can starts. Can You help me with this?

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 //set rtc
#include <LiquidCrystal.h>

//******************** Define LCD setting ********************
// Connections:
// rs (LCD pin 4) to Arduino pin 22
// rw (LCD pin 5) to Arduino pin Gnd
// enable (LCD pin 6) to Arduino pin 23
// LCD pins d4, d5, d6, d7 to Arduino pins 24, 25 26, 27
LiquidCrystal lcd(22,23,24,25,26,27);

//*************** Define line2 LED setting ***************

int line2 = 2; // line2 LED connected to PWM digital pin 2

int line2rampup = 5 ; // time for line2 LEDs to dim on and off in minutes
int line2rampdown = 5 ; // time for line2 LEDs to dim on and off in minutes

int line2min = 0 ; // minimmum dimming value of line2 LEDs, range of 0-255
int line2max = 255 ; // maximum dimming value of line2 LEDs, range of 0-255

int photoperiod2 = 2 ; // amount of time array is on at full power in minutes
int ontime2 = 5 ; // time of day (hour, 24h clock) to begin photoperiod2 fade in

//*************** Define line3 LED setting ***************

int line3 = 3; // line3 LED connected to PWM digital pin 3

int line3rampup = 7 ; // time for line3 LEDs to dim on and off in minutes
int line3rampdown = 7 ; // time for line3 LEDs to dim on and off in minutes

int line3min = 0 ; // minimmum dimming value of line3 LEDs, range of 0-255
int line3max = 255 ; // maximum dimming value of line3 LEDs, range of 0-255

int photoperiod3 = 1 ; // amount of time array is on at full power in minutes
int ontime3 = 5 ; // time of day (hour, 24h clock) to begin photoperiod3 fade in

//***************************** RTC DS1307 ********************************

// 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());
}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  D E F I N E  :  O N E S E C O N D |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void onesecond() //function that runs once per second while program is running
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  lcd.setCursor(0, 0);
  if(hour>0)
  {
    if(hour<=12)
    {
      lcd.print(hour, DEC);
    }
    else
    {
      lcd.print(hour-12, DEC);
    }
  }
  else
  {
    lcd.print("12");
  }
  lcd.print(":");
  if (minute < 10) {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  //lcd.print(":");
  //if (second < 10) {
  //  lcd.print("0");
  //}
  //lcd.print(second, DEC);
  if(hour<12)
  {
    lcd.print("AM");
  }
  else
  {
    lcd.print("PM");
  }
  lcd.print(" ");
  delay(1000);
}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  S E T U P  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void setup()
{
//***************************** RTC DS1307 ********************************

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 Wire.begin();

 // Change these values to what you want to set your clock to.
 // You probably only want to set your clock once and then remove
 // the setDateDs1307 call.
 second = 50;
 minute = 59;
 hour = 4;
 dayOfWeek = 6;
 dayOfMonth = 3;
 month = 11;
 year = 12;
 setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
//***************************** LED DISPLAY LINES INFO ********************************
 lcd.begin(20, 4); // set up the LCD's number of rows and columns:
 analogWrite(line2, line2min);
 lcd.setCursor(0, 1);
 lcd.print("B:");
 lcd.setCursor(2, 1);
 lcd.print(33*line2min/85);
 lcd.print(" ");
 analogWrite(line3, line3min);
 lcd.setCursor(5, 1);
 lcd.print("W:");
 lcd.setCursor(7, 1);
 lcd.print(33*line3min/85);


}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  L O O P |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void loop() {

//***************************** LOOP RTC DS1307 ********************************
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);





//||||||||||||||||||||||||| LINES LED LOOP |||||||||||||||||||||||||
//********** Fade line2 LED from min. to max. **********
int daybyminute2 = ((hour * 60) + minute);if (daybyminute2 >= (ontime2*60))
 if (daybyminute2 <= ((ontime2*60) + line2rampup) - minute) //if time is in range of fade in, start fading in
  for(int line2fadeval = line2min ; line2fadeval <= line2max; line2fadeval ++) // sets the minimum and maximum values

 {analogWrite(line2, line2fadeval);
 lcd.setCursor(2, 1);
 lcd.print(33*line2fadeval/85);
 lcd.print(" ");
 
 int countdown = ((line2rampup*60)/(line2max-line2min));
 while (countdown>0)
 {onesecond();countdown--;}}



//********** Fade line3 LED from min. to max. **********

int daybyminute3 = ((hour * 60) + minute);if (daybyminute3 >= (ontime3*60))
  if (daybyminute3 <= ((ontime3*60) + line3rampup) - minute)
  for(int line3fadeval = line3min ; line3fadeval <= line3max; line3fadeval ++)


 {analogWrite(line3, line3fadeval);
 lcd.setCursor(7, 1);
 lcd.print(33*line3fadeval/85);
 lcd.print(" ");
 int countdown = ((line3rampup*60)/(line3max-line3min));
 while (countdown>0)
 {onesecond();countdown--;}}



onesecond();
 
}
Logged

Radelaide!
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi new2ard,

First - you will want to format your code and place them into code tags (the # button in the editor on the forums).

As for the code - I can see a few problems already, but will need some time to make the code a bit more readable smiley

EDIT:

Looking at the code - you have two for loops running in the main loop. This would probably explain the behaviour you are getting. Just to be sure, do you realise that loop is run constantly?

The way the code is set up now - you are stalling the main loop from further processing with each call to onesecond. what you might want to do is look at the Blink without delay sketch and work that into what you are doing. For example - removing the for loops and calculating the values on each pass of the main loop.

Added some braces to your code so it's a bit easier to read
Code:
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 //set rtc
#include <LiquidCrystal.h>

//******************** Define LCD setting ********************
// Connections:
// rs (LCD pin 4) to Arduino pin 22
// rw (LCD pin 5) to Arduino pin Gnd
// enable (LCD pin 6) to Arduino pin 23
// LCD pins d4, d5, d6, d7 to Arduino pins 24, 25 26, 27
LiquidCrystal lcd(22,23,24,25,26,27);

//*************** Define line2 LED setting ***************

int line2 = 2; // line2 LED connected to PWM digital pin 2

int line2rampup = 5 ; // time for line2 LEDs to dim on and off in minutes
int line2rampdown = 5 ; // time for line2 LEDs to dim on and off in minutes

int line2min = 0 ; // minimmum dimming value of line2 LEDs, range of 0-255
int line2max = 255 ; // maximum dimming value of line2 LEDs, range of 0-255

int photoperiod2 = 2 ; // amount of time array is on at full power in minutes
int ontime2 = 5 ; // time of day (hour, 24h clock) to begin photoperiod2 fade in

//*************** Define line3 LED setting ***************

int line3 = 3; // line3 LED connected to PWM digital pin 3

int line3rampup = 7 ; // time for line3 LEDs to dim on and off in minutes
int line3rampdown = 7 ; // time for line3 LEDs to dim on and off in minutes

int line3min = 0 ; // minimmum dimming value of line3 LEDs, range of 0-255
int line3max = 255 ; // maximum dimming value of line3 LEDs, range of 0-255

int photoperiod3 = 1 ; // amount of time array is on at full power in minutes
int ontime3 = 5 ; // time of day (hour, 24h clock) to begin photoperiod3 fade in

//***************************** RTC DS1307 ********************************

// 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());
}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  D E F I N E  :  O N E S E C O N D |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void onesecond() //function that runs once per second while program is running
{
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
    getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
    lcd.setCursor(0, 0);
    if(hour>0)
    {
        if(hour<=12)
        {
            lcd.print(hour, DEC);
        }
        else
        {
            lcd.print(hour-12, DEC);
        }
    }
    else
    {
        lcd.print("12");
    }

    lcd.print(":");

    if (minute < 10)
    {
        lcd.print("0");
    }

    lcd.print(minute, DEC);
    //lcd.print(":");
    //if (second < 10) {
    //  lcd.print("0");
    //}
    //lcd.print(second, DEC);
    if(hour<12)
    {
        lcd.print("AM");
    }
    else
    {
        lcd.print("PM");
    }

    lcd.print(" ");

    delay(1000);
}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  S E T U P  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void setup()
{
    //***************************** RTC DS1307 ********************************

    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
    Wire.begin();

    // Change these values to what you want to set your clock to.
    // You probably only want to set your clock once and then remove
    // the setDateDs1307 call.
    second = 50;
    minute = 59;
    hour = 4;
    dayOfWeek = 6;
    dayOfMonth = 3;
    month = 11;
    year = 12;
    setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
    //***************************** LED DISPLAY LINES INFO ********************************
    lcd.begin(20, 4); // set up the LCD's number of rows and columns:
    analogWrite(line2, line2min);
    lcd.setCursor(0, 1);
    lcd.print("B:");
    lcd.setCursor(2, 1);
    lcd.print(33*line2min/85);
    lcd.print(" ");
    analogWrite(line3, line3min);
    lcd.setCursor(5, 1);
    lcd.print("W:");
    lcd.setCursor(7, 1);
    lcd.print(33*line3min/85);


}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  L O O P |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void loop() {

    //***************************** LOOP RTC DS1307 ********************************
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
    getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);





    //||||||||||||||||||||||||| LINES LED LOOP |||||||||||||||||||||||||
    //********** Fade line2 LED from min. to max. **********
    int daybyminute2 = ((hour * 60) + minute);
   
    if (daybyminute2 >= (ontime2*60))
    {
        if (daybyminute2 <= ((ontime2*60) + line2rampup) - minute) //if time is in range of fade in, start fading in
        {
            for(int line2fadeval = line2min ; line2fadeval <= line2max; line2fadeval ++) // sets the minimum and maximum values
            {
                analogWrite(line2, line2fadeval);
                lcd.setCursor(2, 1);
                lcd.print(33*line2fadeval/85);
                lcd.print(" ");

                int countdown = ((line2rampup*60)/(line2max-line2min));
                while (countdown>0)
                {
                    onesecond();
                    countdown--;
                }
            }
        }
    }


    //********** Fade line3 LED from min. to max. **********

    int daybyminute3 = ((hour * 60) + minute);
   
    if (daybyminute3 >= (ontime3*60))
    {
        if (daybyminute3 <= ((ontime3*60) + line3rampup) - minute)
        {
            for(int line3fadeval = line3min ; line3fadeval <= line3max; line3fadeval ++)
            {
                analogWrite(line3, line3fadeval);
                lcd.setCursor(7, 1);
                lcd.print(33*line3fadeval/85);
                lcd.print(" ");
                int countdown = ((line3rampup*60)/(line3max-line3min));
                while (countdown>0)
                {
                    onesecond();
                    countdown--;
                }
            }
        }
    }



    onesecond();
}
« Last Edit: November 06, 2012, 12:20:28 am by SilkyPantsDan » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi SilkyPantsDan,

Sorry, I am new to Arduino and to this forum. Yes I know the loop is runs constantly so I can see the percents show on my display. Is there any way you can edit this code so they both can run the same time?

Thank you for your helps.
Kev.
Logged

DELHI
Offline Offline
God Member
*****
Karma: 8
Posts: 831
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset





can some tell me how did we assigned this address:#define DS1307_I2C_ADDRESS 0x68  . how we get this I2c address









Hello,

I am so new to this and I have a problem with this program. This code supposed to have two lines start at the same time, but some how only one starts and other wait till its finished before its can starts. Can You help me with this?

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 //set rtc
#include <LiquidCrystal.h>

//******************** Define LCD setting ********************
// Connections:
// rs (LCD pin 4) to Arduino pin 22
// rw (LCD pin 5) to Arduino pin Gnd
// enable (LCD pin 6) to Arduino pin 23
// LCD pins d4, d5, d6, d7 to Arduino pins 24, 25 26, 27
LiquidCrystal lcd(22,23,24,25,26,27);

//*************** Define line2 LED setting ***************

int line2 = 2; // line2 LED connected to PWM digital pin 2

int line2rampup = 5 ; // time for line2 LEDs to dim on and off in minutes
int line2rampdown = 5 ; // time for line2 LEDs to dim on and off in minutes

int line2min = 0 ; // minimmum dimming value of line2 LEDs, range of 0-255
int line2max = 255 ; // maximum dimming value of line2 LEDs, range of 0-255

int photoperiod2 = 2 ; // amount of time array is on at full power in minutes
int ontime2 = 5 ; // time of day (hour, 24h clock) to begin photoperiod2 fade in

//*************** Define line3 LED setting ***************

int line3 = 3; // line3 LED connected to PWM digital pin 3

int line3rampup = 7 ; // time for line3 LEDs to dim on and off in minutes
int line3rampdown = 7 ; // time for line3 LEDs to dim on and off in minutes

int line3min = 0 ; // minimmum dimming value of line3 LEDs, range of 0-255
int line3max = 255 ; // maximum dimming value of line3 LEDs, range of 0-255

int photoperiod3 = 1 ; // amount of time array is on at full power in minutes
int ontime3 = 5 ; // time of day (hour, 24h clock) to begin photoperiod3 fade in

//***************************** RTC DS1307 ********************************

// 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());
}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  D E F I N E  :  O N E S E C O N D |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void onesecond() //function that runs once per second while program is running
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  lcd.setCursor(0, 0);
  if(hour>0)
  {
    if(hour<=12)
    {
      lcd.print(hour, DEC);
    }
    else
    {
      lcd.print(hour-12, DEC);
    }
  }
  else
  {
    lcd.print("12");
  }
  lcd.print(":");
  if (minute < 10) {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  //lcd.print(":");
  //if (second < 10) {
  //  lcd.print("0");
  //}
  //lcd.print(second, DEC);
  if(hour<12)
  {
    lcd.print("AM");
  }
  else
  {
    lcd.print("PM");
  }
  lcd.print(" ");
  delay(1000);
}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  S E T U P  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void setup()
{
//***************************** RTC DS1307 ********************************

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 Wire.begin();

 // Change these values to what you want to set your clock to.
 // You probably only want to set your clock once and then remove
 // the setDateDs1307 call.
 second = 50;
 minute = 59;
 hour = 4;
 dayOfWeek = 6;
 dayOfMonth = 3;
 month = 11;
 year = 12;
 setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
//***************************** LED DISPLAY LINES INFO ********************************
 lcd.begin(20, 4); // set up the LCD's number of rows and columns:
 analogWrite(line2, line2min);
 lcd.setCursor(0, 1);
 lcd.print("B:");
 lcd.setCursor(2, 1);
 lcd.print(33*line2min/85);
 lcd.print(" ");
 analogWrite(line3, line3min);
 lcd.setCursor(5, 1);
 lcd.print("W:");
 lcd.setCursor(7, 1);
 lcd.print(33*line3min/85);


}


/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  L O O P |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/

void loop() {

//***************************** LOOP RTC DS1307 ********************************
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);





//||||||||||||||||||||||||| LINES LED LOOP |||||||||||||||||||||||||
//********** Fade line2 LED from min. to max. **********
int daybyminute2 = ((hour * 60) + minute);if (daybyminute2 >= (ontime2*60))
 if (daybyminute2 <= ((ontime2*60) + line2rampup) - minute) //if time is in range of fade in, start fading in
  for(int line2fadeval = line2min ; line2fadeval <= line2max; line2fadeval ++) // sets the minimum and maximum values

 {analogWrite(line2, line2fadeval);
 lcd.setCursor(2, 1);
 lcd.print(33*line2fadeval/85);
 lcd.print(" ");
 
 int countdown = ((line2rampup*60)/(line2max-line2min));
 while (countdown>0)
 {onesecond();countdown--;}}



//********** Fade line3 LED from min. to max. **********

int daybyminute3 = ((hour * 60) + minute);if (daybyminute3 >= (ontime3*60))
  if (daybyminute3 <= ((ontime3*60) + line3rampup) - minute)
  for(int line3fadeval = line3min ; line3fadeval <= line3max; line3fadeval ++)


 {analogWrite(line3, line3fadeval);
 lcd.setCursor(7, 1);
 lcd.print(33*line3fadeval/85);
 lcd.print(" ");
 int countdown = ((line3rampup*60)/(line3max-line3min));
 while (countdown>0)
 {onesecond();countdown--;}}



onesecond();
 
}

Logged

AMPS

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

can some tell me how did we assigned this address:#define DS1307_I2C_ADDRESS 0x68  . how we get this I2c address

This is a cross-post of this, right?

can some tell me how did we assigned this address:#define DS1307_I2C_ADDRESS 0x68  . how we get this I2c address
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In what way did the other thread not answer your question?

Please do not cross post!
Logged


Pages: [1]   Go Up
Jump to: