#define mic_pin A0
#define IR_pin 6
#define voice 400#define voice 400
if (voice_data > voice && take == false)
{
time = millis();
num++;
delay(10);
Serial.println(num);
if (num > 20)
{
take = true;
takePhoto();
Serial.println("takePhoto...");
}
}
else if (millis() - time > 1000 )//1s之后才可以再次拍摄
{
voice_data = analogRead(mic_pin);
if (voice_data < voice)
{
num = 0;
take = false;
}
time = millis();
}
void takePhoto()
{
for (int i = 0; i < 3; i++)
{
irsend.sendSony(PHOTO, 20); // Sony code
delay(10);
}
}