An error I can't figure out

Hi all, I have been working on this program and cannot seem to figure it out. First off I am using arduino 0021 for this program. It contains a clock and temperature program. Both programs work separately but when combined I get only 1 message at the end of it. I get this :
expected unqualified-id before '{' token Here is the code:

/*

originally written by Christian, cptbjorn@gmail.com

*/
#include "Wire.h" 
#define DS1307_I2C_ADDRESS 0x68 //set rtc
#include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins
#include <OneWire.h>
#include <DallasTemperature.h> 
 LiquidCrystal lcd(12, 13, 4, 5, 6, 7);   // typically 8, 9, 4, 5, 6, 7
                                         // have to change to free up more pwm pins

// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html






// Data wire is plugged into pin 8 on the Arduino
#define ONE_WIRE_BUS 9

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

// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

//DeviceAddress insideThermometer = { 0x28, 0x3C, 0xF2, 0xA7, 0x02, 0x00, 0x00, 0xCB };
DeviceAddress outsideThermometer = { 0x28, 0x20, 0x04, 0xA8, 0x02, 0x00, 0x00, 0x4D };

void setup(void)
{
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
//sensors.setResolution(insideThermometer, 10);
sensors.setResolution(outsideThermometer, 10);

//pinMode(backLight, OUTPUT);
//digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
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);
//lcd.print("/");
lcd.print(DallasTemperature::toFahrenheit(tempC));
}
}

void loop(void)
{ 
delay(2000);
sensors.requestTemperatures();
//lcd.setCursor(0,0);
//lcd.print("In: ");
//printTemperature(insideThermometer);
lcd.setCursor(0,1);
lcd.print("Out: ");
printTemperature(outsideThermometer);

}
// int pwm_one = 10;       // extra pwm pin for future use
// int pwm_one = 9;        // extra pwm pin for future use
//const int ledPin1 =  2;          // pin number for relay 1
//const int ledPin2 =  8;          // pin number for relay 2
 // pinMode(ledPin1, OUTPUT);    // set the digital pin as output:
 // pinMode(ledPin2, OUTPUT);    // set the digital pin as output:
  


byte decToBcd(byte val)    // Convert normal decimal numbers to binary coded decimal
{
  return ( (val/10*16) + (val%10) );
}


byte bcdToDec(byte val)    // Convert binary coded decimal to normal decimal numbers
{
  return ( (val/16*10) + (val%16) );
}


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

 
//void loop() 

//{
   // onesecond();
    
 // byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs1307(&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 = 00;
  minute = 15;
  hour = 21;
  dayOfWeek = 0;  // Sunday is 0
  dayOfMonth = 11;
  month =12;
  year = 11;
 
// setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
 
  lcd.begin(16, 2); // set up the LCD's number of rows and columns: 
  //  lcd.print("12:00 80.6"); // Print a message to the LCD.
  //  lcd.print(char(223));
  lcd.setCursor(0, 1);
   
  lcd.setCursor(8, 1);
     
}

//void loop()
{
  onesecond();

  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  int daybyminute = ((hour * 60) + minute); //converts time of day to a single value in minutes
      

         onesecond(); // updates clock once per second
       
       {
                   
        }
}  // END LOOP
//void loop()
{
  onesecond();

expected unqualified-id before '{' token Here is the code:

So what is this stuff supposed to be doing? You can't just splatter { in the sketch wherever you like.

Paul, part of the code is for the clock and the other part is for taking a temp reading. Each one works and I just figured I could put them together and that would work. What you are telling me then is I have to when combining these two, I have to tear them apart and build both at the same time to get this to work?

You can spatter {} pairs nearly anywhere you want inside functions. They just must be in pairs.
In your code you are using // to comment out lines but you have not correctly removed the braces.
To me it looks like you missed two of them.
A { as PaulS pointed out just after the commented out void loop() around line 234.
But also one } just above that same commented out loop.

And if you comment out those you will run into the next level of errors
because some of the variables are now redeclared since they will be in the same function.
It almost looks like you wanted to fully comment out the loop() function at the bottom.

If you are wanting to "comment" out a block of code or say an entire function
for some testing, the best/safest way is to use a C preprocessor conditional.

#if 0
code you don't want to be compiled here
#endif

---- bill

What you are telling me then is I have to when combining these two, I have to tear them apart and build both at the same time to get this to work?

That is the best way. You know that they work separately. It should be relatively easy to combine them, if you understand what each does, and how it works.

Ok, then I will try my hand at rewriting this. It should give me valuable practice and much needed learning of code. I figure the worst I can do is not have it work. Thanks for all the responds. :grin:

I felt Generous, so I did some cleaning for you. I've not tested it, but it's 200% easier to read (for me at least)

rjhudak1_untested.pde (4.95 KB)

Thank you for all the input and help. I'll try out the rewrite of it.