pir+ metal detector + water sensor

Can these three sensor be combined in just one program? Can someone help me please!! thanks and more power…

these are the codes that i’ve got!!

//PIR
int pirSensor = 14;

long unsigned int x;

boolean active = true;
boolean notactive;

void setup() {
Serial.begin(9600);

pinMode(pirSensor, INPUT);
digitalWrite(pirSensor, LOW);

Serial.print(“Initializing PIR”); // Initialize PIR sensor for 30 sec
for(int i = 0; i < 30; i++) {
Serial.print(".");
delay(1000);
}
Serial.println(" OK!");
Serial.println(“PIR Ready”);
delay(50);
}

void loop() {
if(digitalRead(pirSensor) == HIGH) { // If motion is detected
if(active) {
active = false;
Serial.println("***");
Serial.print(“Motion detected for “);
Serial.print(millis()/1000);
Serial.println(” sec.”);
delay(50);
}
notactive = true;
}

if(digitalRead(pirSensor) == LOW) { // If motion not detected
if(notactive) {
x = millis();
notactive = false;
}
if(!active && millis() - x > 5000) {
active = true;
Serial.print(“Motion ended for “);
Serial.print((millis() - 5000)/1000);
Serial.println(” sec.”);
delay(50);
}
}
}

// water sensor
int switch_state;
int WaterAnalogValue;

void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
Serial.println(“Water Sensor Test.”);
}

void loop() {
switch_state = digitalRead(15);
if (switch_state == LOW)
{
digitalWrite(13, HIGH);
Serial.println(“Wet Object Detected!”);
}
else
{
digitalWrite(13, LOW);
Serial.println(“NO Wet Object Detected!”);
}

WaterAnalogValue = analogRead(A0);
Serial.print("Analog Value : ");
Serial.println(WaterAnalogValue,DEC);
delay(500);
}

//metal detector
void setup() {
pinMode(16, INPUT);
//pinMode(18, INPUT);
pinMode(17, OUTPUT);
Serial.begin(9600);
Serial.println(“Metal Detector Test.”);
digitalWrite(17, HIGH);
delay(1000);
digitalWrite(17, LOW);
Serial.println(“Ready!”);
}

void loop() {
int DET = digitalRead(16); // Connected to Pin 4
//int POL = digitalRead(18);

if (DET == LOW) { // If metal is detected
Serial.println(“Metal Detected!”);
delay(1000);
}

}

You can combine all sorts of sensors as long as they are not conflicting. So if you can attach each of those sensors to your board, you are able to use and process them. What you did so far is copying and pasting the sample sketches for those sensors here. Did you try them on your board already with the sensors connected to the appropriate port?

yes I already did. What i did was connecting the sensor one by one to the arduino board. What i am going to do is to attach all the sensor on the arduino,but my problem is what would be the code for those three?

I doubt anyone, having read your post, can respond with help since, other than understanding you want to combine codes, we don’t know what you are trying to accomplish beyond that. Here is a place to start. - Scotty

http://forum.arduino.cc/index.php/topic,148850.0.html

skootch down to #7 read it understand it. come back and fix your post.