Digital output won't go LOW.

Greetings! I have a project to control the measuring of conductivity of a solution. I need the solution to fill the container where the conductivity probe will be, then the container need to be emptied to be filled with water for washing up the probe. I will have to control 4 solenoid valves by controlling 4 relays. At a certain time I will have to open the solenoid valve to fill the container with the solution, then I have to close it and open the valve to empty the container and then close it and open the valve to fill the container with water, then close it and it will go on like that. I have the code already and everything is working, with the exception that the solenoid valves aren’t closing after they’re open. I will put my code down below, can anyone help me?

#define SONDA A0

int led_branco = 2;
int led_vermelho = 3;
int led_verde = 4;
int rele_entrasolucao = 5;
int rele_saisolucao = 6;
int rele_entraagua = 7;
int rele_saiagua = 8;
int contador_es;
int contador_ss;
int contador_ea;
int contador_sa;
int contador_geral;
int condutividadeanalog;
float condutividade;

void setup() {
pinMode(rele_entrasolucao, OUTPUT);
pinMode(rele_saisolucao, OUTPUT);
pinMode(rele_entraagua, OUTPUT);
pinMode(rele_saiagua, OUTPUT);
pinMode(led_branco, OUTPUT);
pinMode(led_vermelho, OUTPUT);
pinMode(led_verde, OUTPUT);

void loop() {
digitalWrite(led_branco, HIGH);
if (led_branco = HIGH){
contador_geral = 0;
while (contador_geral < 110){
contador_geral ++;
if (contador_geral = 110){
digitalWrite(led_verde, LOW);
digitalWrite(led_vermelho, HIGH);
digitalWrite(rele_entrasolucao, HIGH);
if (rele_entrasolucao = HIGH){
contador_geral = 111;
Serial.println(“Solucao entrando…”);
contador_es = 0;
while (contador_es < 40){
contador_es ++;
if (contador_es = 40){
digitalWrite(rele_saisolucao, HIGH);
if (rele_saisolucao = HIGH){
digitalWrite(rele_entrasolucao, LOW);
Serial.println(“Solucao saindo…”);
contador_ss = 0;
while (contador_ss < 10){
contador_ss ++;
if (contador_ss = 10){
digitalWrite(rele_entraagua, HIGH);
if (rele_entraagua = HIGH){
digitalWrite(rele_saisolucao, LOW);
Serial.println(“Água entrando…”);
contador_ea = 0;
while (contador_ea < 30){
contador_ea ++;
if (contador_ea >= 10){
digitalWrite(rele_saiagua, HIGH);
if (contador_ea = 30){
digitalWrite(rele_entraagua, LOW);
contador_sa = 0;
while (contador_sa < 15){
contador_sa ++;
if (contador_sa = 15){
digitalWrite(rele_saiagua, LOW);
digitalWrite(led_vermelho, LOW);
digitalWrite(led_verde, HIGH);

All of your if statements are incorrect. ‘==’ is an equal comparison. ‘=’ is an assignment. You are actually doing assignments in your if statements.



digitalWrite(led_branco, HIGH);

if (led_branco = HIGH)

Should be 

if (digitalRead(led_branco) == HIGH)

Good catch

Hello Matheusfr97,
Welcome to the Arduino fora.

Before you do anything else please please take a moment to read General guidance
How to use this forum
Especially item #7 on posting code, then go back to modify your original code using code tags.

I will have to control 4 solenoid valves by controlling 4 relays

A relay is a set of contacts operated by an electromagnet. A solenoid valve is a valve operated by an electromagnet. Whatever is driving the relay could most likely drive the solenoid directly.