lvalue required as left operand of assignment

Hallo ich komm nicht weiter mit einem Problem, ich bekomme die ganze zeit den Fehler:

D:\Eigene Dateien\POLO-Projekt\arduino\Test_7_Q2Schaltung_test_\Test_7_Q2Schaltung_test_.ino: In function 'void loop()':

Test_7_Q2Schaltung_test_:63:81: error: lvalue required as left operand of assignment

if(voltage>=Schwellenwert_St2 && Q2_value==false && Q2_delay==true || Q1_value=true){ // Einschalten Q2;

^~~~

Test_7_Q2Schaltung_test_:63:35: error: label 'Q2_value' used but not defined

if(voltage>=Schwellenwert_St2 && Q2_value==false && Q2_delay==true || Q1_value=true){ // Einschalten Q2;

^~~~~~~~

exit status 1
lvalue required as left operand of assignment

Hier ist mein Code:

#define Q1 2
#define Q2 3
#define Spannungsteiler1 0
#define Spannungsteiler2 5
#define Shunt1 1
#define Shunt2 2
#define Schwellenwert_St2
#define period 100
#define umrechnungsfaktor 0.1;//abhängig von Messungen mit Schunt
int temp_st=0;
int voltage=0;

unsigned long time_st=0;

int temp_sh=0;
int amp=0;
int ampreturn=0;
unsigned long time_sh=0;

bool Q1_value = false;
bool Q1_delay = true;

bool Q2_value = false;
bool Q2_delay = false;

long time_test=0;
unsigned long time_delay=0;
void setup() {
pinMode(Q1, OUTPUT);
pinMode(Q2, OUTPUT);
pinMode(Spannungsteiler1, INPUT);
pinMode(Spannungsteiler2, INPUT);
digitalWrite(Q2,HIGH);
digitalWrite(Q1,LOW);//testzwecke
Serial.begin(9600);
time_st = millis();
time_sh = millis();
time_test = millis();
time_delay = millis();
temp_st=analogRead(Spannungsteiler1)*0.9;
temp_sh=0;
}

void loop() {

if((unsigned long)(millis() - time_st) >= period){// Auslesung Spannungsteiler 2;
voltage=analogRead(Spannungsteiler2);
voltage=(voltage0.1)+temp_st;
temp_st=voltage
0.9;
time_st = millis();
}

if((unsigned long)(millis() - time_sh) >= period){// Auslesung Shunt2;
amp=analogRead(Shunt2);
amp=(amp0.1)+temp_sh;
temp_sh=amp
0.9;
time_sh = millis();
ampreturn=amp*umrechnungsfaktor;// temporär für bessere fisualisierung;
}

test();

if(voltage>=Schwellenwert_St2 && Q2_value==false && Q2_delay==true || Q1_value=true){ // Einschalten Q2;
digitalWrite(Q2,LOW);
Q2_value=true;
Q2_delay=false;
time_delay = millis();
}

if(voltage<=Schwellenwert_St2&&Q2_value==true&&Q2_delay==true&&Q1_value==false&&Q1_delay==true){// Ausschalten Q2;
digitalWrite(Q2,HIGH);
Q2_value=false;
Q2_delay=false;
time_delay = millis();
}

if((unsigned long)(millis() - time_delay) >= period*50){// Delay, damit das relay nur alle 5s geschaltet werden kann und somit nicht flattern kann;
Q2_delay=true;
}

}

void test(){
if((unsigned long)(millis() - time_test) >= period){// Auslesung Shunt1;
Serial.print(voltage);
Serial.print(" ");
Serial.print(amp);
Serial.print(" ");
Serial.println(ampreturn);
time_test = millis();
}
}

Kann mir bitte jemand helfen

Q1_value=true

You probably meant

Q1_value==true

#define umrechnungsfaktor 0.1; Be very, very careful when putting semicolons at the the end of preprocessor macros

Did you forget something here?

#define Schwellenwert_St2

TheMemberFormerlyKnownAsAWOL:

#define umrechnungsfaktor 0.1;

Be very, very careful when putting semicolons at the the end of preprocessor macros

david_2018:
Did you forget something here?

#define Schwellenwert_St2

That's why you shouldn't be using macros to define constants. The preprocessor is a stupid text processor, it just copies and pastes text, it doesn't care about type safety or syntax rules.

Use the compiler to handle your constants, that'll avoid hard to spot bugs an cryptic error messages later on.

constexpr float umrechnungsfaktor = 0.1;

(Idem for all other #defines in your code, every one of them can - and should - be replaced by a constant.)

Pieter

Omg thank you for all your help, it works now.
I look so stupid right now, may be I shoundn´t code for 10 hours next time XD

PieterP:
That's why you shouldn't be using macros to define constants. The preprocessor is a stupid text processor, it just copies and pastes text, it doesn't care about type safety or syntax rules.

Use the compiler to handle your constants, that'll avoid hard to spot bugs an cryptic error messages later on.

constexpr float umrechnungsfaktor = 0.1;

(Idem for all other #defines in your code, every one of them can - and should - be replaced by a constant.)

Pieter

First thank you for your help.
My intention for useing macros (#define) was to save dynamic storage, am I wrong about that?

albertepple:
First thank you for your help.
My intention for useing macros (#define) was to save dynamic storage, am I wrong about that?

Macros will not save dynamic memory. Compilers are very smart, they perform constant propagation and many other optimizations to eliminate unnecessary variables.

Even if they did save memory, premature optimization is the root of all evil.

PieterP:
Macros will not save dynamic memory. Compilers are very smart, they perform constant propagation and many other optimizations to eliminate unnecessary variables.

Even if they did save memory, premature optimization is the root of all evil.

Ok thank you for your help, I will try to implement your suggestions.