hey all, i dont know what i did wrong ? what do you think ?
i dont know what i did wrong ?
You posted three images.
i m not allowed to it in a forum ?
It is much better if you post the actual code, using code tags when you do
Why download 40k of image when a few hundred bytes of text would provide the same experience?
ok im sorry
so my code :
void Verif_Pres_Cycle(int floor_number, bool cycle_state) {
if (floor_number == 1) {
if ( cycle_state == true)
{Serial.print("\t");
Serial.print("cycle en cours");
}
else {Serial.print("\t");
Serial.print("pas de cycle en cours");
}
}
else if (floor_number == 2) {
if ( cycle_state == true)
{Serial.print("\t");
Serial.print("cycle en cours");
}
else {Serial.print("\t");
Serial.print("pas de cycle en cours");
}
}
else { Serial.print("No floor choosen"); }
}
void Mes_PG_PB(int floor_number , float culture_params_global[4] , float culture_params_mes[2] ){
MesTempHum( floor_number); // DHT param Hum1/2 Temp1/2 depend de l'etage choisi.
delay(2000);
Serial.print("\t");
Serial.print("------------");
Serial.print("\t");
MesTempRes(); //DS18 param : TemperRes
delay(2000);
//compare param Tres gen & Tparam res base : ( pas de peltier pour le moment )
// if( TemperRes > (temp_res_ideal + delta_temp_res_ideal) ){}
//else if (TemperRes < (temp_res_ideal + delta_temp_res_ideal) ) {}
//else {}
Serial.print("------------");
// Serial.print(MesTempHum(floor_number));
Serial.print("------------");
Serial.print("\t");
ActivVentil( floor_number, *&culture_params_global , *&culture_params_mes );
delay(2000);
//float param_mes[1] = { TempRes };
}
void Verif_Param(){
}
void Lance_Cycle(int floor_number, float cycle_state ,float culture_params_global[4] , float culture_params_mes[2] ){
Verif_Pres_Cycle( floor_number, cycle_state);
Mes_PG_PB( floor_number , *&culture_params_global , *&culture_params_mes );
Serial.print("\t");
Serial.print("etage : ");
Serial.print(floor_number);
Serial.print("\t");
Serial.print("etat cycle : ");
Serial.print(cycle_state);
Serial.print("\t");
Serial.print("param glob : ");
Serial.print(*culture_params_global );
Serial.print("\t");
Serial.print("param mes : ");
Serial.print(*culture_params_mes);
}
void loop() {
// put your main code here, to run repeatedly:
//------- Aquisition des parametres -----------
//------Alim actionneurs--------
Serial.print("\t");
Lance_Cycle(1, true , *&culture_params_global , *&culture_params_mes );
// Verif_Pres_Cycle( 1, true);
// Mes_PG_PB( floor_number , *&culture_params_global , *&culture_params_mes );
}
error:
C:----------------------------------------\Borago\Borago.ino: In function 'void loop()':
Borago:616:63: error: 'culture_params_mes' was not declared in this scope
Lance_Cycle(1, true , *&culture_params_global , *&culture_params_mes );
^
exit status 1
'culture_params_mes' was not declared in this scope
So where is culture_params_mes declared ?
float MesTempHum(int floor_number){
float hum , temper;
if(floor_number == 1) {
hum = Hum1;
temper = Temp1;
Temp1 = dht1.readTemperature();
Hum1 = dht1.readHumidity();
Serial.print("Humidite etage 1: ");
Serial.print(Hum1);
Serial.print("\t");
Serial.print("Temperature etage 1: ");
Serial.print(Temp1);
Serial.print(" *C ");
Serial.print("\t");
Serial.print("culture param mes etage 1: ");
float culture_params_mes[2] = {hum,temper};
Serial.print(culture_params_mes[2]);
return culture_params_mes[2];
}
else if(floor_number == 2) {
hum = Hum2;
temper = Temp2;
The variables you declare as function parameters are limited in scope to that function. This is why you can use the culture_params_mes variables in your Mes_PG_PB and Lance_Cycle functions, but not in your loop function.
More information:
https://www.arduino.cc/reference/en/language/variables/variable-scope--qualifiers/scope/
lgabed420:
float MesTempHum(int floor_number){
Where did that come from? That was not part of the original code you posted. It's very unhelpful to post fragments of code. We need to see it all. Regardless, the new snippet you posted does not change my answer above.
you want the code ?
If the problem is clear to you and you have no more questions about it, then we can consider this thread resolved and there is no need for the full code. However, in any future forum threads you create please be sure to post your complete code.
ok thank you , so how call this variables to loop function ?
If you want a variable to be accessible from all scopes, you make it global by declaring it outside of the functions.
You need to understand is that you currently have three separate local variables named culture_params_mes in your code. One is local to the the Mes_PG_PB function scope. One is local to the Lance_Cycle function scope. The last is local to the if block scope in your MesTempHum function. These functions have absolutely nothing to do with each other.
It's unclear to me what you're trying to accomplish in your code, so I think you'll need to provide a clear description before we can answer your question.
THIS VARIABLE IS
If you think that qualifies as the "clear description" I requested then you might as well just give up on your project now.
sorry it wasn t my reply --' just something was gone wrong !
so the variabiale culture_params_mes is a measure from dht sensor in the MesTempHum function, and i want to use it in an others functions, i dont know how becaus you told me that this variable is unknown outside my function.
do you have any idea please ?
do you have any idea please ?
Make it a global variable. Then you don't need to pass it to and return it from functions and it will be available everywhere in the program
it's a measure from a sensor so can i do it ? kind do it like this ? :
#define DHTTYPE DHT22
#define DHT1_PIN 2
DHT dht1 (DHT1_PIN, DHTTYPE);
float hum , temper;
hum = Hum1;
temper = Temp1;
Temp1 = dht1.readTemperature();
Hum1 = dht1.readHumidity();
Serial.print("Humidite etage 1: ");
Serial.print(Hum1);
Serial.print("\t");
Serial.print("Temperature etage 1: ");
Serial.print(Temp1);
Serial.print(" *C ");
Serial.print("\t");
Serial.print("culture param mes etage 1: ");
float culture_params_mes[2] = {hum,temper};
Serial.print(culture_params_mes[2]);
i had two sensor, so this is why i had do it in a function with a IF condition for choosen the one i want to use