Statement problem !!!

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Statement problem !!!

Postby alung92 » Wed Jan 21, 2015 11:56 pm

HI, i doing my final year project. my project tile is automatic roof system. i using 3 types of sensors {rain sensor,DHT11(temperature n humidity) and LDR }, 2 limit switch and 1 dc geared motor .which mean input is sensor output is motor. My design for this project got 3 conditions to active the motor.
1)Detect the rain then active the motor and directly close the roof
2)when the humidity increase and temperature decreasing until certain set point, motor will active. (close roof)
3)LDR is only detect the daylight, when sunlight getting dim mean night time, the motor also active.(close roof)

Meanwhile other than this 3 condition is opening roof.
The problem that i encounter is when i try to combine all coding, i cant make it . i not really expert in program C. someone plz help me correct my coding. thx a lot. i will appreciate it .
CODE: SELECT_ALL_CODE
#include "DHT.h"
#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
DHT dht;
int LDR = 3;
int LDRValue=0;
int humidity= 0;
int temperature=0;
int tempValue=0;
int daynight=400;
int temp_sensitivity=33;
int humidity_sensitivity=60;

const int buttonState = 4;
int E1 = 6; 
int M1 = 7;
                       
 
void setup()
{
  dht.setup(2);
  Serial.begin(9600);
 
pinMode(buttonState,INPUT);
digitalWrite(4, HIGH);
lcd.begin(16, 2);
  lcd.clear();

pinMode(M1, OUTPUT);

}

void loop()

{

  int value;
LDRValue = analogRead(LDR);
 
delay(dht.getMinimumSamplingPeriod());

  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();

 // Serial.print(dht.getStatusString());
  lcd.setCursor(0,0);
  lcd.print("Humidity");
 lcd.setCursor(0,1);
  lcd.print(humidity, 1);
 
   lcd.setCursor(6,1);
  lcd.print(LDRValue, 1);
 
lcd.setCursor(12,0);
  lcd.print("Temp");
  lcd.setCursor(12, 1);
  lcd.print(temperature, 1);

if (LDRValue > daynight)
  {
 
   lcd.clear();
    lcd.print("Night mode");
 delay(1000);
    lcd.clear();
    if (buttonState == LOW) {   //limit switch recoil
   
    digitalWrite(M1, LOW);    //motor forward motion
    analogWrite(E1, 1);   
  delay(50);
   
 
 lcd.print("ROOF ClOSED");
    delay(2000);
   
   }
 
  }
  else {
     analogWrite(E1, 0);  //motor stop moving
    delay(50);
  }
  }

   
 if (temperature> temp_sensitivity)
 {
if ( humidity> humidity_sensitivity)
   {
    if(buttonState == LOW)   //limit switch recoil
     {   
   lcd.clear();
    lcd.print("ROOF OPENED");
    delay(1000);
   lcd.clear();
   
    digitalWrite(M1, HIGH);  //motor reverse motion   
   analogWrite(E1, 255);   
  delay(50);
    } }
   else {
    analogWrite(E1, 0); 
    delay(50);
      }
    }

  }
alung92
Novice
 
Posts: 17
Joined: Thu Aug 21, 2014 12:57 pm

Re: Statement problem !!!

Postby ober » Fri Jan 23, 2015 11:44 am

It is not possible for us to combine project without hardware in front of us.

My advise, try to load single project code and modify from it, adding code slowly and verify it. Step by step.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 27 guests