you start with one of the sketches and
- merge global variables,
- merge functions
- merge includes
- merge the setup() code
- merge the loop code()
in every merge step you should resolve conflicting names, #parameters etc.
do that for every additional sketch.
So step one would lead to - note there are some conflicts to resolve!
// set pin numbers:
const int soundPin = 2; // the number of the Sound sensor pin
const int ledPin = 13; // the number of the LED pin
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int ledPin = 13; // LED connected to digital pin 13
const int lightPin = 2;
const int ledPin = 13;
int value = 0;
int sensorValue = 0; // value read from the sensor
// variables will change:
int soundState = 0; // variable for reading the sound sensor status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the sound sensor pin as an input:
pinMode(soundPin, INPUT);
}
void loop(){
// read the state of the sound sensor value:
soundState = digitalRead(soundPin);
// check if any sound is detected.
// if it is, the sound sensor is :PW:
if (soundState == LOW) {
// turn LED on:
digitalWrite(ledPin, HIGH);
delay(60000);
//wait 60 seconds and turn it off
digitalWrite(ledPin, LOW);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}