Pages: [1]   Go Down
Author Topic: error: expected constructor, destructor, or type conversion  (Read 9706 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

anyone help please i have a errors in this program

Code:
#include <SD.h>
#include <LiquidCrystal.h>

int CS_pin = 53;

volatile long lastSave = 0; // time value of last save. Relies on realtime clock
volatile long lcdTimeOut = 0; //timer for turning off LCD
volatile int saveInterval = 10; //time between saves (units = seconds, not millis)
volatile int lcdInterval= 60; //time to wait before shutting off LCD (units = seconds)
const int reps = 9; //number of temp readings to average per channel (count from zero)

LiquidCrystal lcd(8,3,4,5,6,7); //RS,EN,DB4,DB5,DB6,DB7


#define muxA0 15
#define muxA1 16
#define muxA2 17
#define tempPin 0
#define lcdLight 9
#define button1 2                   
int button1INT = 0;

#define aref_voltage 1.1

const int chs = 8;
const int numReadings = 10;
long tempInArray[numReadings][chs];
int index = 0;
long total[chs];
float averages[chs];

//*****************************************************************************************
void error(char *str)
{
  lcd.clear();
  lcd.home();
  lcd.print("error: ");
  lcd.print(str);
  while(1);
}

//****************************************************************************************

void setup(void)
{
  Serial.begin(9600);
  analogReference(INTERNAL1V1);
  pinMode(muxA2, OUTPUT);
  pinMode(muxA1, OUTPUT);
  pinMode(muxA0, OUTPUT);
  pinMode(button1, INPUT);
  digitalWrite(lcdLight, HIGH);

  lcd.begin(20,4);  //(columns,rows)
  lcd.setCursor(0,0);
  lcd.print("Tugas Akhir");
  lcd.setCursor(0,1);
  lcd.print("Miniatur Hujan Salju");
  delay (5000);
  lcd.clear();
 
  lcd.setCursor(0,0);
  lcd.print ("Oleh: ");
  lcd.setCursor(0,1);
  lcd.print ("Mochamad Rikki Firmansyah");
  lcd.setCursor(0,2);
  lcd.print ("dan");
  lcd.setCursor(0,3);
  lcd.print ("Ichsan T Primanizar");
  delay (5000);
  lcd.clear();
  //**************************************************************************
  //initialize the SD card
  if (!SD.begin(CS_pin))
    {
      lcd.setCursor(0,0);
      lcd.println ("Card Failure ");
      delay (3000);
      lcd.clear();
      return;
    }
      lcd.println ("Card Ready");
      delay (3000);
      lcd.clear();
     
  //Membaca Konfigurasi command.txt
  File commandFile = SD.open ("COMMAND.txt");
  if (commandFile)
  {
    lcd.setCursor(0,0);
    lcd.println ("Membaca File");
    delay (3000);
    lcd.clear();
    while (commandFile.available());
  }
  else
  {
    lcd.println ("File Tdk Trsedia");
    delay (3000);
    lcd.clear();
  }
 
 
  //Write log file
  File logFile = SD.open ("LOG.csv", FILE_WRITE);
  if (logFile)
  {
    logFile.println (", , , , , , , ,");
    String header = "Ch1, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7, Ch8";
    logFile.println (header);
    logFile.close();
  }
  else
  {
    lcd.setCursor (0,0);
    lcd.print  ("data failed");
    delay (2000);
    lcd.clear();
  }
 
 
}

  //***************************************************************************
  // Have user select save-data interval and lcd timeout
  // These two lines call sub-routines that are down at the bottom of this file
  saveInterval = saveInt(); //call saveInt sub-function and return value
  lcdInterval = lcdInt();   //call lcdInt sub-function and return value
  //*******************************************************************************
 
  // initialize analog temperature value array

  for (int channel = 0; channel < chs; channel++) {
    for (int i = 0; i < numReadings; i++) {
      tempInArray[i][channel] = 0;
    }
  }

i had a errors is
Code:
sketch_jul03c:169: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul03c:170: error: expected constructor, destructor, or type conversion before '=' token
sketch_jul03c:175: error: expected unqualified-id before 'for'
sketch_jul03c:175: error: expected constructor, destructor, or type conversion before '<' token
sketch_jul03c:175: error: expected constructor, destructor, or type conversion before '++' token
Logged

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

Code:
//***************************************************************************
// Have user select save-data interval and lcd timeout
// These two lines call sub-routines that are down at the bottom of this file
saveInterval = saveInt(); //call saveInt sub-function and return value
lcdInterval = lcdInt();   //call lcdInt sub-function and return value
//*******************************************************************************

// initialize analog temperature value array

for (int channel = 0; channel < chs; channel++) {
  for (int i = 0; i < numReadings; i++) {
    tempInArray[i][channel] = 0;
  }
}

You can't just declare stuff like that outside a function. You need to put it inside a function such as void loop(){}, or void setup(){};


I think this is what you were trying to do:
Code:
#include <SD.h>
#include <LiquidCrystal.h>

int CS_pin = 53;

volatile long lastSave = 0; // time value of last save. Relies on realtime clock
volatile long lcdTimeOut = 0; //timer for turning off LCD
volatile int saveInterval = 10; //time between saves (units = seconds, not millis)
volatile int lcdInterval= 60; //time to wait before shutting off LCD (units = seconds)
const int reps = 9; //number of temp readings to average per channel (count from zero)

LiquidCrystal lcd(8,3,4,5,6,7); //RS,EN,DB4,DB5,DB6,DB7


#define muxA0 15
#define muxA1 16
#define muxA2 17
#define tempPin 0
#define lcdLight 9
#define button1 2                   
int button1INT = 0;

#define aref_voltage 1.1

const int chs = 8;
const int numReadings = 10;
long tempInArray[numReadings][chs];
int index = 0;
long total[chs];
float averages[chs];

//*****************************************************************************************
void error(char *str)
{
  lcd.clear();
  lcd.home();
  lcd.print("error: ");
  lcd.print(str);
  while(1);
}

//****************************************************************************************

void setup(void)
{
  Serial.begin(9600);
  analogReference(INTERNAL1V1);
  pinMode(muxA2, OUTPUT);
  pinMode(muxA1, OUTPUT);
  pinMode(muxA0, OUTPUT);
  pinMode(button1, INPUT);
  digitalWrite(lcdLight, HIGH);

  lcd.begin(20,4);  //(columns,rows)
  lcd.setCursor(0,0);
  lcd.print("Tugas Akhir");
  lcd.setCursor(0,1);
  lcd.print("Miniatur Hujan Salju");
  delay (5000);
  lcd.clear();

  lcd.setCursor(0,0);
  lcd.print ("Oleh: ");
  lcd.setCursor(0,1);
  lcd.print ("Mochamad Rikki Firmansyah");
  lcd.setCursor(0,2);
  lcd.print ("dan");
  lcd.setCursor(0,3);
  lcd.print ("Ichsan T Primanizar");
  delay (5000);
  lcd.clear();
  //**************************************************************************
  //initialize the SD card
  if (!SD.begin(CS_pin))
  {
    lcd.setCursor(0,0);
    lcd.println ("Card Failure ");
    delay (3000);
    lcd.clear();
    return;
  }
  lcd.println ("Card Ready");
  delay (3000);
  lcd.clear();

  //Membaca Konfigurasi command.txt
  File commandFile = SD.open ("COMMAND.txt");
  if (commandFile)
  {
    lcd.setCursor(0,0);
    lcd.println ("Membaca File");
    delay (3000);
    lcd.clear();
    while (commandFile.available());
  }
  else
  {
    lcd.println ("File Tdk Trsedia");
    delay (3000);
    lcd.clear();
  }


  //Write log file
  File logFile = SD.open ("LOG.csv", FILE_WRITE);
  if (logFile)
  {
    logFile.println (", , , , , , , ,");
    String header = "Ch1, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7, Ch8";
    logFile.println (header);
    logFile.close();
  }
  else
  {
    lcd.setCursor (0,0);
    lcd.print  ("data failed");
    delay (2000);
    lcd.clear();
  }
 
//Moved brace from here...

  //***************************************************************************
  // Have user select save-data interval and lcd timeout
  // These two lines call sub-routines that are down at the bottom of this file
  saveInterval = saveInt(); //call saveInt sub-function and return value
  lcdInterval = lcdInt();   //call lcdInt sub-function and return value
  //*******************************************************************************
 
  // initialize analog temperature value array
 
  for (int channel = 0; channel < chs; channel++) {
    for (int i = 0; i < numReadings; i++) {
      tempInArray[i][channel] = 0;
    }
  }
 
} //To here...
« Last Edit: July 03, 2012, 11:33:35 am by TCWORLD » Logged

~Tom~

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

ok thanks
Logged

Pages: [1]   Go Up
Jump to: