Error = Void does not name a type??

Hi peeps. I am trying to work out a code for a project at work. I have limited experience with programing from studying at uni so I am very raw plus I have not done anything now with arduino for over 12 months. When checking my code for errors I am get a message
error: void does not name a type

I dont think this is a major one and it is something I should know. Can anyone point me in the right direction? Here is the code I have written if anyone fancies a look and can help me out??

//pin for which phosphine inputs into arduino

Int PHOS_IN_A1 = 1;

//pin for which the boron inputs into the arduino

Int BOR_IN_A2 = 2;

//pin for which the arsine inputs into the arduino

Int ARS_IN_A3 = 3;

//pin for which the beam gate a side inputs into the arduino

Int BGA_IN_A4 = 4;

//pin for which beam gate b side inputs the arduino

Int BGB_IN_A5 = 4;

//now to declare integers of any other peripherals

//dep timer connection

Int DEP_TIME = 12;

// beam gate a side timer connection

Int A_SIDE = 11;

//beam gate b side timer connection

Int B_SIDE = 10;

void setup()

{
Serial.begin(9600); // this is how chip communicates with pc
}
//set TIMER pins as outputs 

pinMode(DEP_TIME, OUTPUT);

pinMode(A_SIDE, OUTPUT);

pinMode(B_SIDE, OUTPUT);

//setting the reference voltage to the default setting

analogReference(DEFAULT);

}

 

 

 

Void loop()

{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

For(int i=0; i <10; i++)

 aRead += analogRead(PHOS_IN_A1);//  reads the value from the Phos

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

Voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

Voltage = voltage*1000;

 //when the phos is running

If( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}

Void loop()

{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

For(int i=0; i <10; i++)

 aRead += analogRead(BOR_IN_A2);//  reads the value from the boron

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

Voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

Voltage = voltage*1000;

 //when the boron  is running

If( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}

Void loop()

{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

For(int i=0; i <10; i++)

 aRead += analogRead(ARS_IN_A3);//  reads the value from the arsine

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

Voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

Voltage = voltage*1000;

 //when the arsine  is running

If( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}

Void loop()

{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

For(int i=0; i <10; i++)

 aRead += analogRead(BGA_IN_A4);//  reads the value from the beamgate a side

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

Voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

Voltage = voltage*1000;

 //when the phos is running

If( voltage <= 2000 ) // less than 2V

{

digitalWrite(A_SIDE, HIGH);// turns on the beam gate a side timer

}

Void loop()

{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

For(int i=0; i <10; i++)

 aRead += analogRead(BGB_IN_A5);//  reads the value from the beamgate b side

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

Voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

Voltage = voltage*1000;

 //when the phos is running

If( voltage <= 2000 ) // less than 2V

{

digitalWrite(B_SIDE, HIGH);// turns on the beam gate b side timer

}

 

//print debug info to serial console

    Serial.print("Analog: ");

    Serial.print(aRead);

    Serial.print(" Voltage:");

    Serial.println(voltage);

       //short 1 sec delay between measurements

    delay(1000);

}

// Written by David Eastwood for 160xp dep timer project

Can you provide a link to the documentation for the Int data type? No such thing exists. int, yes. Int, no.

pinMode(DEP_TIME, OUTPUT);

pinMode(A_SIDE, OUTPUT);

pinMode(B_SIDE, OUTPUT);

//setting the reference voltage to the default setting

analogReference(DEFAULT);

All executable code, like this, belongs inside a function. This is not inside a function.

}

Put this back in your pocket. You're sure to need it in the right place, later.

You have so many things capitalized that should not be. Int, Void, For, etc. all start with lower case letters.

You have "void loop()" five times. It should only be there once.

and you have an extraneous end brace:

{
Serial.begin(9600); // this is how chip communicates with pc
}   // <<<<<<<<<<<<<<< This line should be deleted

Pete

Hi Paul

Thanks for the help. Sorry to sound a bit dumb here but what do you mean by the documentation of the integer data type? I honestly have little knowledge of programing and I used a code that I used as part of my degree as a template.

I wish to use the arduino just to trigger 3 different timers. One timer will be running if there is a gas flowing and the other two will be running if isolation valves are open.

Sorry to be so vague and I really am useless here but I do want to try and learn

Dave

but what do you mean by the documentation of the integer data type?

It was a joke, you typed Int not int that is you had a capital letter for the first letter, you do this a lot and it is wrong. Basically your code is riddled with errors. Use the reference option under the help menu to find the right syntax.

C is a case sensitive language, you don't seem to know that.

There is documentation for the various data types that the Arduino uses here:

Notice that there is a link for int, but not one for Int. Case matters.

Did you fingers get stuck on the ctrl and v keys? What's with all the loop() functions?

Thanks for your reply Pete

So I do not need to use seperate loops for each different gas and Isolation valve? I am going to have 5 different inputs into the arduino. 3 of these will give me a voltage from gasses and 2 will give me a voltage from isolation valves. On the output side I will have 3 seperate timers.

The project is for a machine we no longer use that much in work. Rather than perfrom planned maint every 3 or so months. The plan is to do maint after so many hours of gas flowing.

I could have put pressure switches in as all the valves are air activated but I wanted to try and gain a bit more knowledge of Arduino as I quite enjoyed playing about with them last year

Cheers

Dave

Thanks for your reply Pete

Who's Pete?

I know Manchester well, lived there all my life, have you been partaking of your name sake?

PaulS:
There is documentation for the various data types that the Arduino uses here:
Arduino - Home
Notice that there is a link for int, but not one for Int. Case matters.

Did you fingers get stuck on the ctrl and v keys? What's with all the loop() functions?

Cheers paul

Like I said, I have very little knowledge of programing and maybe my enthusiasm took over a little too much. I produced a simple code last year for measuring temperature and triggering various alarms and it worked. I wanted to improve my knowledge of Arduino but becasue of work and studying, I have not had time. When I was assigned this project, I said straight away that I wanted to use an Arduino so I dived right in ( hence the mistakes ).

The 5 loop instuctions are because I thought that I should keep the inputs all seperate. Like I have mentioned, I realise there is mistakes and I need to learn a lot. Thankfully i finish for xmas in the morning so have a few weeks to try and learn without other distractions taking over.

Thanks for your help and advice, I do appreciate it :slight_smile:

Grumpy_Mike:

Thanks for your reply Pete

Who's Pete?

I know Manchester well, lived there all my life, have you been partaking of your name sake?

Sorry Mike :blush:

I was talking to my boss at the same time then and typed Pete instead of Mike

The name comes from New Order and Joy Division albums.

Would you be insinuation Mancunians have a liking for partaking in various things :slight_smile:

I have amended my code and still get the void does not name a type error. Any ideas please peeps

//pin for which phosphine inputs into arduino

int PHOS_IN_A1 = 1;

//pin for which the boron inputs into the arduino

int BOR_IN_A2 = 2;

//pin for which the arsine inputs into the arduino

int ARS_IN_A3 = 3;

//pin for which the beam gate a side inputs into the arduino

int BGA_IN_A4 = 4;

//pin for which beam gate b side inputs the arduino

int BGB_IN_A5 = 4;

//now to declare integers of any other peripherals

//dep timer connection

int DEP_TIME = 12;

// beam gate a side timer connection

int A_SIDE = 11;

//beam gate b side timer connection

int B_SIDE = 10;

void setup()

{
Serial.begin(9600); // this is how chip communicates with pc
}
//set TIMER pins as outputs 

pinMode(DEP_TIME, OUTPUT);

pinMode(A_SIDE, OUTPUT);

pinMode(B_SIDE, OUTPUT);

//setting the reference voltage to the default setting

analogReference(DEFAULT);

}

 

 

 

Void loop()

{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

For(int i=0; i <10; i++)

 aRead += analogRead(PHOS_IN_A1);//  reads the value from the Phos

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

Voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

Voltage = voltage*1000;

 //when the phos is running

If( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

For(int i=0; i <10; i++)

 aRead += analogRead(BOR_IN_A2);//  reads the value from the boron

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the boron  is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(ARS_IN_A3);//  reads the value from the arsine

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the arsine  is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(BGA_IN_A4);//  reads the value from the beamgate a side

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the phos is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(A_SIDE, HIGH);// turns on the beam gate a side timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(BGB_IN_A5);//  reads the value from the beamgate b side

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the phos is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(B_SIDE, HIGH);// turns on the beam gate b side timer

}

 

//print debug info to serial console

    Serial.print("Analog: ");

    Serial.print(aRead);

    Serial.print(" Voltage:");

    Serial.println(voltage);

       //short 1 sec delay between measurements

    delay(1000);

}

// Written by David Eastwood for 160xp dep timer project

So, here's your setup() function:

void setup()

{
Serial.begin(9600); // this is how chip communicates with pc
}

That is followed by a lot of code that is not in a function. Guess what. ALL code must be inside a function, with the exception of global variable declarations and preprocessor directives.

There is a reason that we want you to use Tools + Auto format... before posting code. It makes it easier to see the program logic, and makes it obvious where you have code where it does not belong.

For(int i=0; i <10; i++)

There are no For loops, either.

I have got rid of all the capitals Paul. I uploaded the wrong code from my memory stick

Sorry Paul I got mixed up with the replis then. I realise you mean the auto function on the Arduino sketch pad now.

Hi peeps. Have had a bit of bad news in the family so have been unable to work on my project. Just uploaded to the IDE and am getting an expected, constructor, destructor or type conversion before '(' token, error. When I auto format it, it is saying too many right braces. My code is following, if anyone can help me then I would really appreciate it as I am getting my arse kicked at work unfortunately

//pin for which phosphine inputs into arduino

int PHOS_IN_A1 = 1;

//pin for which the boron inputs into the arduino

int BOR_IN_A2 = 2;

//pin for which the arsine inputs into the arduino

int ARS_IN_A3 = 3;

//pin for which the beam gate a side inputs into the arduino

int BGA_IN_A4 = 4;

//pin for which beam gate b side inputs the arduino

int BGB_IN_A5 = 4;

//now to declare integers of any other peripherals

//dep timer connection

int DEP_TIME = 12;

// beam gate a side timer connection

int A_SIDE = 11;

//beam gate b side timer connection

int B_SIDE = 10;

//set TIMER pins as outputs 

pinMode(DEP_TIME, OUTPUT);

pinMode(A_SIDE, OUTPUT);

pinMode(B_SIDE, OUTPUT);

void setup()

{
Serial.begin(9600); // this is how chip communicates with pc
}



//setting the reference voltage to the default setting

analogReference(DEFAULT);

}

void loop()

{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(PHOS_IN_A1);//  reads the value from the Phos

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the phos is running

If( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(BOR_IN_A2);//  reads the value from the boron

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the boron  is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(ARS_IN_A3);//  reads the value from the arsine

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the arsine  is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(DEP_TIME, HIGH);// turns on the dep timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(BGA_IN_A4);//  reads the value from the beamgate a side

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the phos is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(A_SIDE, HIGH);// turns on the beam gate a side timer

}



{

long aRead = 0; // assumes voltage range from input

float voltage;  // declares a floating number of the voltage

// uses a statement to count up to 10 readings

// which will limit fluctuations when averaged out

for(int i=0; i <10; i++)

 aRead += analogRead(BGB_IN_A5);//  reads the value from the beamgate b side

aRead = aRead/10; // takes the average of 10 readings

  //perform analog to digital conversion

voltage = (aRead * 5.0)/1024.0;

 //converts to millivolts

voltage = voltage*1000;

 //when the phos is running

if( voltage <= 2000 ) // less than 2V

{

digitalWrite(B_SIDE, HIGH);// turns on the beam gate b side timer

}

 

//print debug info to serial console

    Serial.print("Analog: ");

    Serial.print(aRead);

    Serial.print(" Voltage:");

    Serial.println(voltage);

       //short 1 sec delay between measurements

    delay(1000);

}

// Written by David Eastwood for 160xp dep timer project
//setting the reference voltage to the default setting

analogReference(DEFAULT);

All code needs to be inside a function block.

void setup()
{
Serial.begin(9600); // this is how chip communicates with pc
}
//setting the reference voltage to the default setting
analogReference(DEFAULT);
}

Removing the extraneous white space shows that the Auto formatter knows what it is talking about.

I didn’t set up any hardware for this or test it. I just cleaned up the code so it would compile in the IDE so I don't know if this will do what you want it to BUT this should get you on the right track.

Compare this code with what you had and go through the comments again. It may make more sense looking at the question and the answers with some cleaner code.

I removed your comments for clarity.

I will repeat though, I haven't tested this to see if it would really work. It's just a version that would compile. I don't have time to rework it so it will definitely do what you need. This is just a start.

int PHOS_IN_A1 = 1;
int BOR_IN_A2 = 2;
int ARS_IN_A3 = 3;
int BGA_IN_A4 = 4;
int BGB_IN_A5 = 4;
int DEP_TIME = 12;
int A_SIDE = 11;
int B_SIDE = 10;

long aRead = 0;


void setup()
{
Serial.begin(9600);

pinMode(DEP_TIME, OUTPUT);
pinMode(A_SIDE, OUTPUT);
pinMode(B_SIDE, OUTPUT);
}

void loop()
{

float voltage; 

for(int i=0; i <10; i++)
aRead += analogRead(PHOS_IN_A1);
aRead = aRead/10;
voltage = (aRead * 5.0)/1024.0;
voltage = voltage*1000;

if( voltage <= 2000 )
{
digitalWrite(DEP_TIME, HIGH);
}


for(int i=0; i <10; i++)
 aRead += analogRead(BOR_IN_A2);
aRead = aRead/10; 
voltage = (aRead * 5.0)/1024.0;
voltage = voltage*1000;

if( voltage <= 2000 )
{
digitalWrite(DEP_TIME, HIGH);
}

aRead = 0;


for(int i=0; i <10; i++)
 aRead += analogRead(ARS_IN_A3);
aRead = aRead/10; 
voltage = (aRead * 5.0)/1024.0;
voltage = voltage*1000;

if( voltage <= 2000 ) 
{
digitalWrite(DEP_TIME, HIGH);
}

aRead = 0;


for(int i=0; i <10; i++)
 aRead += analogRead(BGA_IN_A4);
aRead = aRead/10; 
voltage = (aRead * 5.0)/1024.0;
voltage = voltage*1000;

if( voltage <= 2000 ) 
{
digitalWrite(A_SIDE, HIGH);
}

aRead = 0;
voltage; 

for(int i=0; i <10; i++)
 aRead += analogRead(BGB_IN_A5);
aRead = aRead/10;
voltage = (aRead * 5.0)/1024.0;
voltage = voltage*1000;

if( voltage <= 2000 )
{
digitalWrite(B_SIDE, HIGH);
}

aRead = 0;

    Serial.print("Analog: ");
    Serial.print(aRead);
    Serial.print(" Voltage:");
    Serial.println(voltage);

    delay(1000);
}

Cheers pal. I will print it off and see if it compares to mine. Hoperfully I will be able to see where I have messed up and take it from there. You and Paul have been a great help and I really appreciate it :slight_smile:

I am going to use the arduino to time how long certain gasses have been running on a machine in work. I know my code was long winded and it has took me a long while to get to the point I am at. But slowly I am starting to get my head round it. Still a way to go but once I have this project sorted at work and I finish uni for the summer then I should have a bit more spare time to spend learning the code and how far I can push an Arduino :slight_smile:

I look forward to hearing how you get it working! Good luck.