Urgent, need help : error: return-statement with a value, in function returning

Hi people ! Since severals days, i continue my program, cause in this part of my program
void loop()
{

int btnRIGHT = analogRead(0);
if(btnRIGHT > 160) return btnRIGHT;
int btnUP = analogRead(145);
if (btnUP > 160) return btnUP;
int btnDOWN = analogRead(330);
if (btnDOWN > 345) return btnDOWN;
int btnLEFT = analogRead(506);
if (btnLEFT > 520) return btnLEFT;
int btnSELECT = analogRead (741);
if (btnSELECT > 760) return btnSELECT;

the function looks like to don't be accepted in the program, wherever i place it.
Do any of you have a solution to solve this problem?
If you need more information, tell me.
PS: Have to finish it in 2 weeks, please, help me to find a solution D:

Use code tags </> for code.

Post all your code when making posts.

With that said, a function can only have one return statement in it. It looks like you are trying to use 5. On top of that the loop function doesn't return anything and isn't supposed to. Though it looks like there is tons you chopped off in your copy paste and we are likely missing relevant information.

This is neither a function, nor is the code worth running anywhere.

I wonder how the compiler figured that out,

apart from the closing '}', void function trying to return something,
abstruse selections of analog ports, ....

ApexM0Eng:
a function can only have one return statement in it.

Fortunately that is not true.

A return statement is just an ordinary C statement.

</> const byte LCD[10] = {

B00111111,B00000110,B01011011,B01001111,B01100110,B01101101,B01111101,B00000111,B01111111,B01101111
};

#include <LiquidCrystal.h>

LiquidCrystal lcd(8,9,4,5,6,7);

int x = 0;
int i = 119;
int s =9;
int ds = 5;
int m=1;
int lcd_key = 0;
int adc_key_in = 0;

#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4

//Feux 1
#define F1V 16
#define F1O 15
#define F1R 14

//Feux 2
#define F2V 19
#define F2O 18
#define F2R 17

// Afficheur S1
#define LATCHS1 28
#define CLOCKS1 26
#define DATAS1 27

// Afficheur DS1
#define LATCHDS1 25
#define CLOCKDS1 23
#define DATADS1 24

// Afficheur M1
#define LATCHM1 22
#define CLOCKM1 20
#define DATAM1 21

// Afficheur S2
#define LATCHS2 37
#define CLOCKS2 35
#define DATAS2 36

// Afficheur DS2
#define LATCHDS2 34
#define CLOCKDS2 32
#define DATADS2 33

// Afficheur M2
#define LATCHM2 31
#define CLOCKM2 29
#define DATAM2 30

void setup()
{

Serial.begin(9600);

pinMode(A0, INPUT);

pinMode(F1V, OUTPUT);
pinMode(F1O, OUTPUT);
pinMode(F1R,OUTPUT);

pinMode(F2V, OUTPUT);
pinMode(F2O, OUTPUT);
pinMode(F2R,OUTPUT);

pinMode(LATCHS1, OUTPUT);
pinMode(CLOCKS1, OUTPUT);
pinMode(DATAS1,OUTPUT);

pinMode(LATCHDS1, OUTPUT);
pinMode(CLOCKDS1, OUTPUT);
pinMode(DATADS1,OUTPUT);

pinMode(LATCHM1, OUTPUT);
pinMode(CLOCKM1, OUTPUT);
pinMode(DATAM1,OUTPUT);

pinMode(LATCHS2, OUTPUT);
pinMode(CLOCKS2, OUTPUT);
pinMode(DATAS2,OUTPUT);

pinMode(LATCHDS2, OUTPUT);
pinMode(CLOCKDS2, OUTPUT);
pinMode(DATADS2,OUTPUT);

pinMode(LATCHM2, OUTPUT);
pinMode(CLOCKM2, OUTPUT);
pinMode(DATAM2,OUTPUT);

Serial.println("Feux de chantier Version 1");
Serial.println("Affichage des feux");
}

void loop()
{
Serial.println ("Feux Rouge 1 fixe, Feux Orange 2 Clignotant");

int btnRIGHT = analogRead(0);
if(btnRIGHT > 160) return btnRIGHT;
int btnUP = analogRead(145);
if (btnUP > 160) return btnUP;
int btnDOWN = analogRead(330);
if (btnDOWN > 345) return btnDOWN;
int btnLEFT = analogRead(506);
if (btnLEFT > 520) return btnLEFT;
int btnSELECT = analogRead (741);
if (btnSELECT > 760) return btnSELECT;

for (int x =0; x<120; x++)
{
</>

Whandall:
Fortunately that is not true.

A return statement is just an ordinary C statement.

Interesting. So it is. I had used compiler in the past that strictly refused to allow more than one exit
to a function. Just got used to the idea.

digitalWrite(LATCHS1,HIGH);

digitalWrite(LATCHDS1,LOW);
shiftOut(DATADS1,CLOCKDS1,MSBFIRST,~(DECOMPTEUR[ds]));
digitalWrite(LATCHDS1,HIGH);

digitalWrite(LATCHM1,LOW);
shiftOut(DATAM1,CLOCKM1,MSBFIRST,~(DECOMPTEUR[m]));
digitalWrite(LATCHM1,HIGH);

Serial.println (i);
Serial.print (m);
Serial.print(":");
Serial.print (ds);
Serial.println (s);

digitalWrite(F1R,HIGH);
digitalWrite(F2O,HIGH);
delay(500);
digitalWrite(F1R,HIGH);
digitalWrite(F2O,LOW);
delay(500);
i--;
s--;
if (s<0){
ds--;
s=9;
if (ds<0){
m--;
ds=5;
}
}

}
x=0;
i=119;
s=9;
ds=5;
m=1;

digitalWrite(F1R,LOW);

Serial.println ("Feux Rouge 2 fixe, Feux Orange 1 Clignotant");

for (int x =0; x<120; x++)
{
digitalWrite(LATCHS2,LOW);
shiftOut(DATAS2,CLOCKS2,MSBFIRST,~(DECOMPTEUR));
digitalWrite(LATCHS2,HIGH);

digitalWrite(LATCHDS2,LOW);
shiftOut(DATADS2,CLOCKDS2,MSBFIRST,~(DECOMPTEUR[ds]));
digitalWrite(LATCHDS2,HIGH);

digitalWrite(LATCHM2,LOW);
shiftOut(DATAM2,CLOCKM2,MSBFIRST,~(DECOMPTEUR[m]));
digitalWrite(LATCHM2,HIGH);

Serial.println (i);
Serial.print (m);
Serial.print(":");
Serial.print (ds);
Serial.println (s);

digitalWrite(F2R,HIGH);
digitalWrite(F1O,HIGH);
delay(500);
digitalWrite(F2R,HIGH);
digitalWrite(F1O,LOW);
delay(500);
i--;
s--;
if (s<0){
ds--;
s=9;
if (ds<0){
m--;
ds=5;
}
}
}
x=0;
i=119;
s=9;
ds=5;
m=1;
digitalWrite(F2R,LOW);

}

Xhellwang: USE CODE TAGS.

The loop function is defined to return void. That means it can't return a value.

But the bigger question for the OP is, why do you want to return a value from loop? Where do you think that returned value is going? What are you trying to accomplish here? It would be better to tell us that and let us help you figure out how it works because you obviously have some serious misunderstanding on what return is supposed to do.

The arduino has two functions by default (necessary). These are run above the C code that you can't see.
setup() is the first function, it is only run once, allowing you to set variables, etc. once the arduino is reset.

loop() is then run, and it repeats itself, over and over. From here you may want to call your functions, and when they return, they return back into the loop() [at the next line from where they were called]

Please use code tags to show your code. The code tags are the top left icon on the editor </>

Delta_G:
The loop function is defined to return void. That means it can't return a value.

But the bigger question for the OP is, why do you want to return a value from loop? Where do you think that returned value is going? What are you trying to accomplish here? It would be better to tell us that and let us help you figure out how it works because you obviously have some serious misunderstanding on what return is supposed to do.

I have to control traffic lights, for a work at school. Here, those traffic lights F1V, F1O, F1R, F2V, F2O, F2R are activing the time we wanted and it work.
We also have to get a text on a terminal (serial.println, work too).
We are using the return function in aim to control the time display on the virtual traffics lights, with buttons from LCD (everything is "virtual", on ISIS).
What i did what see by the best of us and he didn't saw what was wrong lol...
I don't how to explain it goodly in english :frowning:

Xhellwang:
</> const byte LCD[10] = {

So instead of clicking the code button, he typed in what's written on the code button.

This does not bode well.

Xhellwang:
I have to control traffic lights, for a work at school. Here, those traffic lights F1V, F1O, F1R, F2V, F2O, F2R are activing the time we wanted and it work.
We also have to get a text on a terminal (serial.println, work too).
We are using the return function in aim to control the time display on the virtual traffics lights, with buttons from LCD (everything is "virtual", on ISIS).
What i did what see by the best of us and he didn't saw what was wrong lol...
I don't how to explain it goodly in english :frowning:

Friend,
Your "problem" has little to do with your English or what your program should do.

Read the ENTIRE error message - your post title cut-off the IMPORTANT part.

Than ASK you teacher to explain functions and how "function return value" instead of continuing ( wasting your time ) here with irrelevant code details.

Using functions in code is not difficult, but you need to have some basic understanding how they work first.

Best of luck to you.

PS Small advise for future - posts titles with "Urgent..." are NOT appropriate / polite.

int btnLEFT = analogRead(506);

Is not valid. 506 is not a PIN number.