Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 270 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

Temperature Sensorsensor bugs

My project is based on a moving fan using dht11DHT11 sensors.I I have used 2 void loops and the IDE is showing an error "exit status 1 redefinition of 'void loop()'"

"exit status 1 redefinition of 'void loop()'"

One doubt:Can Can we use 2 void loops in the code.Please? Please see and identify the errors.

2nd Doubtdoubt:dht DHT; dht DHT; shows error "exit status 1 'dht' does not name a type" for my version of Arduino 1.8.1

"exit status 1 'dht' does not name a type" for my version of Arduino 1.8.1

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
 

 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
dht DHT;
#define pwm 9
 

void setup() {
  // put your setup code here, to run once:
 
 
    
    

}

void loop() {
  // put your main code here, to run repeatedly:
   // put your setup code here, to run once:
  lcd.begin(16, 2);
 
  lcd.clear();
  lcd.print(" Fan Speed");
  lcd.setCursor(0,1);
  lcd.print(" Controlling");
  delay(2000);
  analogWrite(pwm, 255);
  lcd.clear();
  lcd.print("Circuit Digest ");
  delay(2000); 
}

  void loop() {
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF");
      delay(100);
    }
    
    else if(temp==26)
    {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%");
      delay(100);
    }
    
     else if(temp==27)
    {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%");
      delay(100);
    }
    
     else if(temp==28)
    {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%");
      delay(100);
    }
    
    else if(temp==29)
    {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%");
      delay(100);
    }
     else if(temp>29)
    {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%");
      delay(100);
    }
  delay(3000);
 
}

 
}

Temperature Sensor bugs

My project is based on a moving fan using dht11 sensors.I have used 2 void loops and the IDE is showing an error "exit status 1 redefinition of 'void loop()'"

One doubt:Can we use 2 void loops in the code.Please see and identify the errors.

2nd Doubt:dht DHT; shows error "exit status 1 'dht' does not name a type" for my version of Arduino 1.8.1

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
 

 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
dht DHT;
#define pwm 9
 

void setup() {
  // put your setup code here, to run once:
 
 
    
    

}

void loop() {
  // put your main code here, to run repeatedly:
   // put your setup code here, to run once:
 lcd.begin(16, 2);
 
  lcd.clear();
 lcd.print(" Fan Speed");
 lcd.setCursor(0,1);
 lcd.print(" Controlling");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("Circuit Digest ");
 delay(2000);}

  void loop(){
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF");
      delay(100);
    }
    
    else if(temp==26)
    {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%");
      delay(100);
    }
    
     else if(temp==27)
    {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%");
      delay(100);
    }
    
     else if(temp==28)
    {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%");
      delay(100);
    }
    
    else if(temp==29)
    {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%");
      delay(100);
    }
     else if(temp>29)
    {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%");
      delay(100);
    }
  delay(3000);
 
}

 
}

Temperature sensor bugs

My project is based on a moving fan using DHT11 sensors. I have used 2 void loops and the IDE is showing an error

"exit status 1 redefinition of 'void loop()'"

One doubt: Can we use 2 void loops in the code? Please see and identify the errors.

2nd doubt: dht DHT; shows error

"exit status 1 'dht' does not name a type" for my version of Arduino 1.8.1

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>

 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
dht DHT;
#define pwm 9

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  lcd.clear();
  lcd.print(" Fan Speed");
  lcd.setCursor(0,1);
  lcd.print(" Controlling");
  delay(2000);
  analogWrite(pwm, 255);
  lcd.clear();
  lcd.print("Circuit Digest ");
  delay(2000); 
}

void loop() {
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 ) {
    analogWrite(9,0);
    lcd.print("Fan OFF");
    delay(100);
  } else if(temp==26) {
    analogWrite(pwm, 51);
    lcd.print("Fan Speed: 20%");
    delay(100);
  } else if(temp==27) {
    analogWrite(pwm, 102);
    lcd.print("Fan Speed: 40%");
    delay(100);
  } else if(temp==28) {
    analogWrite(pwm, 153);
    lcd.print("Fan Speed: 60%");
    delay(100);
  } else if(temp==29) {
    analogWrite(pwm, 204);
    lcd.print("Fan Speed: 80%");
    delay(100);
  } else if(temp>29) {
    analogWrite(pwm, 255);
    lcd.print("Fan Speed: 100%");
    delay(100);
  }
  delay(3000);
}
}
Bumped by Community user
added 92 characters in body
Source Link

2nd Doubt:dht DHT; shows error "exit status 1 'dht' does not name a type" for my version of Arduino 1.8.1

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>


 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
intdht DHT;
#define pwm 9


void setup() {
  // put your setup code here, to run once:
 
 
    
    

}

void loop() {
  // put your main code here, to run repeatedly:
   // put your setup code here, to run once:
 lcd.begin(16, 2);
 
 lcd.clear();
 lcd.print(" Fan Speed");
 lcd.setCursor(0,1);
 lcd.print(" Controlling");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("Circuit Digest ");
 delay(2000);}

  void loop(){
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF");
      delay(100);
    }
    
    else if(temp==26)
    {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%");
      delay(100);
    }
    
     else if(temp==27)
    {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%");
      delay(100);
    }
    
     else if(temp==28)
    {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%");
      delay(100);
    }
    
    else if(temp==29)
    {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%");
      delay(100);
    }
     else if(temp>29)
    {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%");
      delay(100);
    }
  delay(3000);

}


}
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>


 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
int DHT;
#define pwm 9


void setup() {
  // put your setup code here, to run once:
 
 
    
    

}

void loop() {
  // put your main code here, to run repeatedly:
   // put your setup code here, to run once:
 lcd.begin(16, 2);
 
 lcd.clear();
 lcd.print(" Fan Speed");
 lcd.setCursor(0,1);
 lcd.print(" Controlling");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("Circuit Digest ");
 delay(2000);}

  void loop(){
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF");
      delay(100);
    }
    
    else if(temp==26)
    {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%");
      delay(100);
    }
    
     else if(temp==27)
    {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%");
      delay(100);
    }
    
     else if(temp==28)
    {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%");
      delay(100);
    }
    
    else if(temp==29)
    {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%");
      delay(100);
    }
     else if(temp>29)
    {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%");
      delay(100);
    }
  delay(3000);

}


}

2nd Doubt:dht DHT; shows error "exit status 1 'dht' does not name a type" for my version of Arduino 1.8.1

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>


 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
dht DHT;
#define pwm 9


void setup() {
  // put your setup code here, to run once:
 
 
    
    

}

void loop() {
  // put your main code here, to run repeatedly:
   // put your setup code here, to run once:
 lcd.begin(16, 2);
 
 lcd.clear();
 lcd.print(" Fan Speed");
 lcd.setCursor(0,1);
 lcd.print(" Controlling");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("Circuit Digest ");
 delay(2000);}

  void loop(){
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF");
      delay(100);
    }
    
    else if(temp==26)
    {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%");
      delay(100);
    }
    
     else if(temp==27)
    {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%");
      delay(100);
    }
    
     else if(temp==28)
    {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%");
      delay(100);
    }
    
    else if(temp==29)
    {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%");
      delay(100);
    }
     else if(temp>29)
    {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%");
      delay(100);
    }
  delay(3000);

}


}
added 274 characters in body
Source Link
Mark Smith
  • 2.2k
  • 1
  • 11
  • 14

#include <DHT.h> #include <DHT_U.h> #include <Adafruit_Sensor.h>

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>


 // Including library for dht

#include<LiquidCrystal.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7); #define dht_dpin 12 int DHT; #define pwm 9

void setup() { // put your setup code here, to run once:

}

void loop() { // put your main code here, to run repeatedly: // put your setup code here, to run once: lcd.begin(16, 2);

lcd.clear(); lcd.print(" Fan Speed"); lcd.setCursor(0,1); lcd.print(" Controlling"); delay(2000); analogWrite(pwm, 255); lcd.clear(); lcd.print("Circuit Digest "); delay(2000);}

void loop(){ DHT.read11(dht_dpin); int temp=DHT.temperature; lcd.setCursor(0,0); lcd.print("Temperature:"); lcd.print(temp); // Printing temperature on LCD

lcd.print("oC"); lcd.setCursor(0,1); if(temp <26 ) { analogWrite(9,0); lcd.print("Fan OFF"); delay(100); }

#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
int DHT;
#define pwm 9


void setup() {
  // put your setup code here, to run once:
 
 
    
    

}

void loop() {
  // put your main code here, to run repeatedly:
   // put your setup code here, to run once:
 lcd.begin(16, 2);
 
 lcd.clear();
 lcd.print(" Fan Speed");
 lcd.setCursor(0,1);
 lcd.print(" Controlling");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("Circuit Digest ");
 delay(2000);}

  void loop(){
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF");
      delay(100);
    }
    
    else if(temp==26)
    {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%");
      delay(100);
    }
    
     else if(temp==27)
    {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%");
      delay(100);
    }
    
     else if(temp==28)
    {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%");
      delay(100);
    }
    
    else if(temp==29)
    {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%");
      delay(100);
    }
     else if(temp>29)
    {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%");
      delay(100);
    }
  delay(3000);

}


}

delay(3000);

}

}

#include <DHT.h> #include <DHT_U.h> #include <Adafruit_Sensor.h>

 // Including library for dht

#include<LiquidCrystal.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7); #define dht_dpin 12 int DHT; #define pwm 9

void setup() { // put your setup code here, to run once:

}

void loop() { // put your main code here, to run repeatedly: // put your setup code here, to run once: lcd.begin(16, 2);

lcd.clear(); lcd.print(" Fan Speed"); lcd.setCursor(0,1); lcd.print(" Controlling"); delay(2000); analogWrite(pwm, 255); lcd.clear(); lcd.print("Circuit Digest "); delay(2000);}

void loop(){ DHT.read11(dht_dpin); int temp=DHT.temperature; lcd.setCursor(0,0); lcd.print("Temperature:"); lcd.print(temp); // Printing temperature on LCD

lcd.print("oC"); lcd.setCursor(0,1); if(temp <26 ) { analogWrite(9,0); lcd.print("Fan OFF"); delay(100); }

else if(temp==26)
{
  analogWrite(pwm, 51);
  lcd.print("Fan Speed: 20%");
  delay(100);
}

 else if(temp==27)
{
  analogWrite(pwm, 102);
  lcd.print("Fan Speed: 40%");
  delay(100);
}

 else if(temp==28)
{
  analogWrite(pwm, 153);
  lcd.print("Fan Speed: 60%");
  delay(100);
}

else if(temp==29)
{
  analogWrite(pwm, 204);
  lcd.print("Fan Speed: 80%");
  delay(100);
}
 else if(temp>29)
{
  analogWrite(pwm, 255);
  lcd.print("Fan Speed: 100%");
  delay(100);
}

delay(3000);

}

}

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>


 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
int DHT;
#define pwm 9


void setup() {
  // put your setup code here, to run once:
 
 
    
    

}

void loop() {
  // put your main code here, to run repeatedly:
   // put your setup code here, to run once:
 lcd.begin(16, 2);
 
 lcd.clear();
 lcd.print(" Fan Speed");
 lcd.setCursor(0,1);
 lcd.print(" Controlling");
 delay(2000);
 analogWrite(pwm, 255);
 lcd.clear();
 lcd.print("Circuit Digest ");
 delay(2000);}

  void loop(){
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 )
    { 
      analogWrite(9,0);
      lcd.print("Fan OFF");
      delay(100);
    }
    
    else if(temp==26)
    {
      analogWrite(pwm, 51);
      lcd.print("Fan Speed: 20%");
      delay(100);
    }
    
     else if(temp==27)
    {
      analogWrite(pwm, 102);
      lcd.print("Fan Speed: 40%");
      delay(100);
    }
    
     else if(temp==28)
    {
      analogWrite(pwm, 153);
      lcd.print("Fan Speed: 60%");
      delay(100);
    }
    
    else if(temp==29)
    {
      analogWrite(pwm, 204);
      lcd.print("Fan Speed: 80%");
      delay(100);
    }
     else if(temp>29)
    {
      analogWrite(pwm, 255);
      lcd.print("Fan Speed: 100%");
      delay(100);
    }
  delay(3000);

}


}
Source Link
Loading