Pages: [1] 2   Go Down
Author Topic: help clock temperature code  (Read 543 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi im all new to this and would be most appreciative if sombody could help with this code for a clock temperature its giving me the error msg

clock:108: error: expected unqualified-id before '{' token

heres the code

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 8;
#define ONE_WIRE_BUS 13

OneWire oneWire(ONE_WIRE_BUS);


DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28, 0x2B, 0x12, 0x0D, 0x04, 0x00, 0x00, 0xAC};


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 dayMonth,
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(dayMonth));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.write(0x10);
Wire.endTransmission();
}

void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayMonth,
byte *month,
byte *year)
{

Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f);
*dayOfWeek = bcdToDec(Wire.read());
*dayMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}
void setup()
{

sensors.begin();

sensors.setResolution(insideThermometer, 10);

pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH);
lcd.begin(16,2);
lcd.clear();
}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
} else {
lcd.print(tempC);


}
}

{byte second, minute, hour, dayOfWeek, dayMonth, month, year;
Wire.begin();
Serial.begin(9600);
second = 0;
minute = 42;
hour = 9;
dayOfWeek = 1;
dayMonth = 3;
month = 10;
year = 10;
lcd.begin(16, 2);

{
void loop()

delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);

printTemperature(insideThermometer);
lcd.print(char(223));
lcd.print('C');
}
{
byte second, minute, hour, dayOfWeek, dayMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayMonth, &month, &year);
lcd.clear();
lcd.setCursor(7,0);
lcd.print(" ");
lcd.print(hour, DEC);
lcd.print(":");
if (minute<10)
{
lcd.print("0");
}
lcd.print(minute, DEC);
lcd.print(":");
if (second<10)
{
lcd.print("0");
}
lcd.print(second, DEC);
lcd.setCursor(0,1);
lcd.print(" ");
switch(dayOfWeek){
case 7:
lcd.print("Sun");
break;
case 1:
lcd.print("Mon");
break;
case 2:
lcd.print("Tue");
break;
case 3:
lcd.print("Wed");
break;
case 4:
lcd.print("Thu");
break;
case 5:
lcd.print("Fri");
break;
case 6:
lcd.print("Sat");
break;
}
lcd.print(" ");
lcd.print(" ");
lcd.print(dayMonth, DEC);
lcd.print("/");
lcd.print(month, DEC);
lcd.print("/20");
lcd.print(year, DEC);
delay(1000);
}



Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
{
void loop()

That doesn't look right. It also agrees with auto-format's 'too many left curly braces' message. I think that should be a closing brace instead. I recommend the use of auto-format - Ctrl-t/Cmd-t.
Logged

Leeds, UK
Online Online
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The whole of this bit is just floating in the middle of nowhere and appears to serve no purpose.
Code:
{byte second, minute, hour, dayOfWeek, dayMonth, month, year;
Wire.begin();
Serial.begin(9600);
second = 0;
minute = 42;
hour = 9;
dayOfWeek = 1;
dayMonth = 3;
month = 10;
year = 10;
lcd.begin(16, 2);

{


The next bit is not quite right either.
Code:
void loop()

delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);

printTemperature(insideThermometer);
lcd.print(char(223));
lcd.print('C');
}
{
Should be:
Code:
[code]void loop(){

delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);

printTemperature(insideThermometer);
lcd.print(char(223));
lcd.print('C');
[/code]
« Last Edit: August 04, 2012, 02:52:01 pm by Tom Carpenter » Logged

~Tom~

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

dont want to sound dumb but im confused ive never messed with code before
Logged

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

any more input still stuck
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
any more input still stuck
"I made some code changes. I won't tell you what they were. I still need help"

Perhaps, my rephrasing of your comment will help you see what you need to do.
Logged

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

changed a few bits but im not sure how this has affected its two codes combined getting these errors

clock:17: error: expected unqualified-id before '[' token
clock:109: error: expected unqualified-id before '{' token
clock:128: error: expected unqualified-id before '[' token
clock:138: error: expected unqualified-id before '{' token

Code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <LiquidCrystal.h> // we need this library for the LCD commands
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);


#define ONE_WIRE_BUS 13
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28, 0x2B, 0x12, 0x0D, 0x04, 0x00, 0x00, 0xAC};

// 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.write(0);
Wire.write(decToBcd(second)); // 0 to bit 7 starts the clock
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.write(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
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.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()
{
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);

lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
} else {
lcd.print(tempC);


}
}

{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);
// 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 = 0;
minute = 42;
hour = 9;
dayOfWeek = 1;
dayOfMonth = 3;
month = 10;
year = 10;

//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
lcd.begin(16, 2); // tells Arduino the LCD dimensions

}
[code]void loop(){

delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);

printTemperature(insideThermometer);
lcd.print(char(223));
lcd.print('C');
}
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
lcd.clear(); // clear LCD screen
lcd.setCursor(7,0);
lcd.print(" ");
lcd.print(hour, DEC);
lcd.print(":");
if (minute<10)
{
lcd.print("0");
}
lcd.print(minute, DEC);
lcd.print(":");
if (second<10)
{
lcd.print("0");
}
lcd.print(second, DEC);
lcd.setCursor(0,1);
lcd.print(" ");
switch(dayOfWeek){
case 7:
lcd.print("Sun");
break;
case 1:
lcd.print("Mon");
break;
case 2:
lcd.print("Tue");
break;
case 3:
lcd.print("Wed");
break;
case 4:
lcd.print("Thu");
break;
case 5:
lcd.print("Fri");
break;
case 6:
lcd.print("Sat");
break;
}
lcd.print(" ");
lcd.print(" ");
lcd.print(dayOfMonth, DEC);
lcd.print("/");
lcd.print(month, DEC);
lcd.print("/20");
lcd.print(year, DEC);
delay(1000);
}
[/code]
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12577
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You seem to have posted two copies of your code so it's hard to know exactly what code you're running.

For goodness' sake, please indent your code. It's like wading through molasses trying to follow the structure of that. For extra brownie points, put each { and } on a separate line with each matching pair indented by the same amount - that style is not universally used but is the one that makes the structure of your code most obvious.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

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

the bottom set is the code im trying to use

ive never done any programming before hard to know where to start
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
hard to know where to start
Start with following Peter's advice to put each { and } on it's own line. Then, use Tools + Auto Format to format the code. Then, post just the code you have questions about.
Logged

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

whats meant by on its own line ?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Each
word
in
this
reply
is
on
its
own
line.
Logged

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

gotcha  smiley-razz

tidied up and auto formatted getting these errors now :

clock:18: error: expected unqualified-id before '[' token
clock:104: error: expected unqualified-id before '{' token
clock:123: error: expected unqualified-id before '[' token
clock:134: error: expected unqualified-id before '{' token

Code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <LiquidCrystal.h>
#define ONE_WIRE_BUS 13
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = {
  0x28, 0x2B, 0x12, 0x0D, 0x04, 0x00, 0x00, 0xAC};

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.write(0);
  Wire.write(decToBcd(second)); // 0 to bit 7 starts the clock
  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.write(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
  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.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()
{
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);

  lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
  lcd.clear(); // start with a blank screen
}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    lcd.print("Error");
  }
  else {
    lcd.print(tempC);


  }
}

{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  Wire.begin();
  Serial.begin(9600);
  // 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 = 0;
  minute = 42;
  hour = 9;
  dayOfWeek = 1;
  dayOfMonth = 3;
  month = 10;
  year = 10;

  //setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
  lcd.begin(16, 2); // tells Arduino the LCD dimensions

}
[code]void loop()
{

  delay(2000);
  sensors.requestTemperatures();
  lcd.setCursor(0,0);

  printTemperature(insideThermometer);
  lcd.print(char(223));
  lcd.print('C');
}
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  lcd.clear(); // clear LCD screen
  lcd.setCursor(7,0);
  lcd.print(" ");
  lcd.print(hour, DEC);
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);
  lcd.setCursor(0,1);
  lcd.print(" ");
  switch(dayOfWeek){
  case 7:
    lcd.print("Sun");
    break;
  case 1:
    lcd.print("Mon");
    break;
  case 2:
    lcd.print("Tue");
    break;
  case 3:
    lcd.print("Wed");
    break;
  case 4:
    lcd.print("Thu");
    break;
  case 5:
    lcd.print("Fri");
    break;
  case 6:
    lcd.print("Sat");
    break;
  }
  lcd.print(" ");
  lcd.print(" ");
  lcd.print(dayOfMonth, DEC);
  lcd.print("/");
  lcd.print(month, DEC);
  lcd.print("/20");
  lcd.print(year, DEC);
  delay(1000);
}



[/code]
Logged

Leeds, UK
Online Online
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
[code]void loop() //Woops, somebody left a [code] tag behind, you need to remove that!
{

  delay(2000);
  sensors.requestTemperatures();
  lcd.setCursor(0,0);

  printTemperature(insideThermometer);
  lcd.print(char(223));
  lcd.print('C');
}//These two brackets aren't needed as the next bit is part of loop()
{
 ...
[/code][/code]
Logged

~Tom~

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Look for comments "MISSING FUNCTION NAME"


Code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>

#define DS1307_I2C_ADDRESS 0x68

#include <LiquidCrystal.h>

#define ONE_WIRE_BUS 13

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28, 0x2B, 0x12, 0x0D, 0x04, 0x00, 0x00, 0xAC };

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.write(0);
        Wire.write(decToBcd(second)); // 0 to bit 7 starts the clock
        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.write(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave

    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.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()
{
    // Start up the library

    sensors.begin();


    // set the resolution to 10 bit (good enough?)

    sensors.setResolution(insideThermometer, 10);

    lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
    lcd.clear(); // start with a blank screen
}

void printTemperature(DeviceAddress deviceAddress)
{
    float tempC = sensors.getTempC(deviceAddress);
    if (tempC == -127.00)
    {
        lcd.print("Error");
    }
    else
    {
        lcd.print(tempC);
    }
}


// MISSING FUNCTION NAME

{
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

    Wire.begin();
    Serial.begin(9600);


    // 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 = 0;
    minute = 42;
    hour = 9;
    dayOfWeek = 1;
    dayOfMonth = 3;
    month = 10;
    year = 10;

//  setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
    lcd.begin(16, 2); // tells Arduino the LCD dimensions
}

void loop()
{
    delay(2000);
    sensors.requestTemperatures();
    lcd.setCursor(0,0);

    printTemperature(insideThermometer);
    lcd.print(char(223));
    lcd.print('C');
}


// MISSING FUNCTION NAME

{
    byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
    getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

    lcd.clear(); // clear LCD screen

    lcd.setCursor(7,0);
    lcd.print(" ");

    lcd.print(hour, DEC);

    lcd.print(":");

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

    lcd.print(":");

    if (second < 10)
    {
        lcd.print("0");
    }
    lcd.print(second, DEC);

    lcd.setCursor(0,1);
    lcd.print(" ");

    switch(dayOfWeek)
    {
        case 7: lcd.print("Sun");   break;
        case 1: lcd.print("Mon");   break;
        case 2: lcd.print("Tue");   break;
        case 3: lcd.print("Wed");   break;
        case 4: lcd.print("Thu");   break;
        case 5: lcd.print("Fri");   break;
        case 6: lcd.print("Sat");   break;
    }

    lcd.print(" ");
    lcd.print(" ");
    lcd.print(dayOfMonth, DEC);
    lcd.print("/");
    lcd.print(month, DEC);
    lcd.print("/20");
    lcd.print(year, DEC);

    delay(1000);
}
« Last Edit: August 05, 2012, 02:52:12 pm by lloyddean » Logged

Pages: [1] 2   Go Up
Jump to: