A problem with Arduino code

Hi i have a problem with this arduino code this message appears in the complining
this is the code

Using library LiquidCrystal at version 1.0.7 in folder: C:\Program Files
exit status 1
'constrain' does not name a type; did you mean 'constexpr'?

// Inclure la bibliothèque code
#include<LiquidCrystal.h>
// Initialiser la bibliothèque en associant un nécessaire à écran LCD interface pin
constrain rs = 4, en = 5, d4 = 6, d5 = 7, d6 = 8, d7 = 9; //
LiquidCrystallcd(rs, en, d4, d5, d6, d7);
// L’arduino pin il est connecté à différents entrées et sorties
Constint
capteurHumidty=A0,nvDeauBas=0,nvDeauHaut=1,Pompe=2,Led=13,buzzer=12,vanne=3;
boolbas,haut;
// Déclaration un entrée analogique
inthumidity,analoghumidity;
voidsetup() {
// Choisir est ce que entrée ou sortie
pinMode(nvDeauBas,INPUT);
pinMode(nvDeauHaut,INPUT);
pinMode(Pompe,OUTPUT);
pinMode(Led,OUTPUT);
pinMode(vanne,OUTPUT);
pinMode(buzzer,OUTPUT);
// le nombre des colonnes et ligne de LCD
lcd.begin(16,2);
// LCD curseur dans la ligne 0 et la colonne 0
lcd.setCursor(0,0);
// Afficher un message dans le LCD
lcd.print("university djilali bounaama");
// // LCD curseur dans la ligne 1 et la colonne 0
lcd.setCursor(0,1);
lcd.print(" theme : systeme irrigation automatique");
// attendre 1s
delay(1000);
// Faites défiler 40 position vers la gauche
for (int positionCounter = 0; positionCounter < 40; positionCounter++) {
// Faites défiler une position gauche
lcd.scrollDisplayLeft();
// attendez un peu de temps
delay(150);
}
// Effacer l’écran
lcd.clear();
lcd.setCursor(0,0);
lcd.print("realiser par :");
delay(1000);
lcd.setCursor(0,0);
lcd.print("lahlouh mohamed ridha");
lcd.setCursor(0,1);
lcd.print("azizou abderrahmane");
delay(1000);
for (int positionCounter = 0; positionCounter < 22; positionCounter++) {
 lcd.scrollDisplayLeft();
 delay(150);
}
}
void loop() {
// Lire l’entrée numérique dans une valeur boolienne
bas=digitalRead(nvDeauBas);
haut=digitalRead(nvDeauHaut);
// Lire l’entrée analogique dans un entier
analoghumidity=analogRead(capteurHumidty);
// Conversation analogique vers numérique
humidity=map(analoghumidity,1023,0,100,0);
// condition de niveau d’eau
if(!haut==HIGH){
if(bas==HIGH){
 digitalWrite(vanne,HIGH);
 tone(buzzer,3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("niveau bas");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
 lcd.print(" %");
 delay(500);
}
else {
 noTone(buzzer);
 lcd.clear();
 lcd.setCursor(0,0);
lcd.print("niveau moyen :");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
 delay(500);
}
}
if(!bas==HIGH){
  if(haut==HIGH){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("niveau haut");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
 lcd.print(" %");
 delay(500);
 }
 else {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("niveau moyen");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
delay(500);
 }
}
// Les conditions d’humidité
if(humidity<=30){
// Pompe marche
 digitalWrite(Pompe,HIGH);
// LED allumé
 digitalWrite(Led,HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Pompe: arroser");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
 delay(500);
 }
 else {
// pompe arret
 digitalWrite(Pompe,LOW);
// led éteindre
digitalWrite(Led,LOW);
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Pompe: arret");
 lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
 }
delay(500);
}
}

Hi i have a problem with this arduino code this message appears in the complining

Using library LiquidCrystal at version 1.0.7 in folder: C:\Program Files
exit status 1
'constrain' does not name a type; did you mean 'constexpr'?

this is the code

// Inclure la bibliothèque code
#include<LiquidCrystal.h>
// Initialiser la bibliothèque en associant un nécessaire à écran LCD interface pin
constrain rs = 4, en = 5, d4 = 6, d5 = 7, d6 = 8, d7 = 9; //
LiquidCrystallcd(rs, en, d4, d5, d6, d7);
// L'arduino pin il est connecté à différents entrées et sorties
Constint
capteurHumidty=A0,nvDeauBas=0,nvDeauHaut=1,Pompe=2,Led=13,buzzer=12,vanne=3;
boolbas,haut;
// Déclaration un entrée analogique
inthumidity,analoghumidity;
voidsetup() {
// Choisir est ce que entrée ou sortie
pinMode(nvDeauBas,INPUT);
pinMode(nvDeauHaut,INPUT);
pinMode(Pompe,OUTPUT);
pinMode(Led,OUTPUT);
pinMode(vanne,OUTPUT);
pinMode(buzzer,OUTPUT);
// le nombre des colonnes et ligne de LCD
lcd.begin(16,2);
// LCD curseur dans la ligne 0 et la colonne 0
lcd.setCursor(0,0);
// Afficher un message dans le LCD
lcd.print("university djilali bounaama");
// // LCD curseur dans la ligne 1 et la colonne 0
lcd.setCursor(0,1);
lcd.print(" theme : systeme irrigation automatique");
// attendre 1s
delay(1000);
// Faites défiler 40 position vers la gauche
for (int positionCounter = 0; positionCounter < 40; positionCounter++) {
// Faites défiler une position gauche
lcd.scrollDisplayLeft();
// attendez un peu de temps
delay(150);
}
// Effacer l'écran
lcd.clear();
lcd.setCursor(0,0);
lcd.print("realiser par :");
delay(1000);
lcd.setCursor(0,0);
lcd.print("lahlouh mohamed ridha");
lcd.setCursor(0,1);
lcd.print("azizou abderrahmane");
delay(1000);
for (int positionCounter = 0; positionCounter < 22; positionCounter++) {
 lcd.scrollDisplayLeft();
 delay(150);
}
}
void loop() {
// Lire l'entrée numérique dans une valeur boolienne
bas=digitalRead(nvDeauBas);
haut=digitalRead(nvDeauHaut);
// Lire l'entrée analogique dans un entier
analoghumidity=analogRead(capteurHumidty);
// Conversation analogique vers numérique
humidity=map(analoghumidity,1023,0,100,0);
// condition de niveau d'eau
if(!haut==HIGH){
if(bas==HIGH){
 digitalWrite(vanne,HIGH);
 tone(buzzer,3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("niveau bas");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
 lcd.print(" %");
 delay(500);
}
else {
 noTone(buzzer);
 lcd.clear();
 lcd.setCursor(0,0);
lcd.print("niveau moyen :");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
 delay(500);
}
}
if(!bas==HIGH){
  if(haut==HIGH){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("niveau haut");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
 lcd.print(" %");
 delay(500);
 }
 else {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("niveau moyen");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
delay(500);
 }
}
// Les conditions d'humidité
if(humidity<=30){
// Pompe marche
 digitalWrite(Pompe,HIGH);
// LED allumé
 digitalWrite(Led,HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Pompe: arroser");
lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
 delay(500);
 }
 else {
// pompe arret
 digitalWrite(Pompe,LOW);
// led éteindre
digitalWrite(Led,LOW);
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Pompe: arret");
 lcd.setCursor(0,1);
lcd.print("humidity ");
lcd.print(humidity);
lcd.print(" %");
 }
delay(500);
}
}

Please always do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.


The error didn't lie. There is no type named constrain. You have several other errors in your code. Please spend some time studying the Arduino Lanaguage reference:

as well as the LiquidCrystal library's tutorials:

"does not name a type" usually means you tried to put a line of code outside any function. That usually means you have an extra '}' or are missing a '{' above the error.

constrain rs = 4, en = 5, d4 = 6, d5 = 7, d6 = 8, d7 = 9;

What do you want this line of code to do ?

Did you perhaps mean

byte rs = 4, en = 5, d4 = 6, d5 = 7, d6 = 8, d7 = 9;

It looks like that code is not valid C, because it declares a variable as type "constrain", but "constrain" is - as the error says - not the name of a type. No more valid than saying

assdfsd rs=4;

Either that code never worked, and it was a typo/mistake in the code you copied, or it was written for a different version of the library which supplied a typedef named "constrain" - the LiquidCrystal and LiquidCrystal_I2C libraries are notorious for existing in dozens of mutually incompatible and/or subtly different versions, all with the same name and often identical readme files and version numbers, fueled by how easy it is to fork repos on github.

I've merged your other cross-post @Laghdaf.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

The sketch has a bunch of typographical errors such a capitalization, missing spaces, and bad autocorrections. It looks like 'constrain' was autocorrected from 'constint'. I corrected that to 'const byte'.

Here is the sketch with the obvious typographical errors fixed:

// Inclure la bibliothèque code
#include<LiquidCrystal.h>


// Initialiser la bibliothèque en associant un nécessaire à écran LCD interface pin
const byte rs = 4, en = 5, d4 = 6, d5 = 7, d6 = 8, d7 = 9;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


// L'arduino pin il est connecté à différents entrées et sorties
const byte capteurHumidty = A0, nvDeauBas = 0, nvDeauHaut = 1, Pompe = 2, Led = 13, buzzer = 12, vanne = 3;
bool bas, haut;


// Déclaration un entrée analogique
int humidity, analoghumidity;


void setup() {
  // Choisir est ce que entrée ou sortie
  pinMode(nvDeauBas, INPUT);
  pinMode(nvDeauHaut, INPUT);
  pinMode(Pompe, OUTPUT);
  pinMode(Led, OUTPUT);
  pinMode(vanne, OUTPUT);
  pinMode(buzzer, OUTPUT);
  // le nombre des colonnes et ligne de LCD
  lcd.begin(16, 2);
  // LCD curseur dans la ligne 0 et la colonne 0
  lcd.setCursor(0, 0);
  // Afficher un message dans le LCD
  lcd.print("university djilali bounaama");
  // // LCD curseur dans la ligne 1 et la colonne 0
  lcd.setCursor(0, 1);
  lcd.print(" theme : systeme irrigation automatique");
  // attendre 1s
  delay(1000);
  // Faites défiler 40 position vers la gauche
  for (int positionCounter = 0; positionCounter < 40; positionCounter++) {
    // Faites défiler une position gauche
    lcd.scrollDisplayLeft();
    // attendez un peu de temps
    delay(150);
  }
  // Effacer l'écran
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("realiser par :");
  delay(1000);
  lcd.setCursor(0, 0);
  lcd.print("lahlouh mohamed ridha");
  lcd.setCursor(0, 1);
  lcd.print("azizou abderrahmane");
  delay(1000);
  for (int positionCounter = 0; positionCounter < 22; positionCounter++) {
    lcd.scrollDisplayLeft();
    delay(150);
  }
}


void loop() 
{
  // Lire l'entrée numérique dans une valeur boolienne
  bas = digitalRead(nvDeauBas);
  haut = digitalRead(nvDeauHaut);


  // Lire l'entrée analogique dans un entier
  analoghumidity = analogRead(capteurHumidty);


  // Conversation analogique vers numérique
  humidity = map(analoghumidity, 1023, 0, 100, 0);


  // condition de niveau d'eau
  if (!haut == HIGH) 
  {
    if (bas == HIGH) 
    {
      digitalWrite(vanne, HIGH);
      tone(buzzer, 3000);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("niveau bas");
      lcd.setCursor(0, 1);
      lcd.print("humidity ");
      lcd.print(humidity);
      lcd.print(" %");
      delay(500);
    }
    else 
    {
      noTone(buzzer);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("niveau moyen :");
      lcd.setCursor(0, 1);
      lcd.print("humidity ");
      lcd.print(humidity);
      lcd.print(" %");
      delay(500);
    }
  }
  
  if (!bas == HIGH) 
  {
    if (haut == HIGH) 
    {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("niveau haut");
      lcd.setCursor(0, 1);
      lcd.print("humidity ");
      lcd.print(humidity);
      lcd.print(" %");
      delay(500);
    }
    else 
    {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("niveau moyen");
      lcd.setCursor(0, 1);
      lcd.print("humidity ");
      lcd.print(humidity);
      lcd.print(" %");
      delay(500);
    }
  }
  
  // Les conditions d'humidité
  if (humidity <= 30) 
  {
    // Pompe marche
    digitalWrite(Pompe, HIGH);
    // LED allumé
    digitalWrite(Led, HIGH);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pompe: arroser");
    lcd.setCursor(0, 1);
    lcd.print("humidity ");
    lcd.print(humidity);
    lcd.print(" %");
    delay(500);
  }
  else 
  {
    // pompe arret
    digitalWrite(Pompe, LOW);
    // led éteindre
    digitalWrite(Led, LOW);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pompe: arret");
    lcd.setCursor(0, 1);
    lcd.print("humidity ");
    lcd.print(humidity);
    lcd.print(" %");
  }
  delay(500);
}