31 lines
669 B
C++
Executable File
31 lines
669 B
C++
Executable File
#define SAMPLE A1
|
|
#define PULSE 13
|
|
boolean STATUS = false;
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
pinMode(SAMPLE, INPUT);
|
|
pinMode(PULSE, INPUT);
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
|
|
delay(2000);
|
|
testStatus();
|
|
Serial.println(STATUS);
|
|
}
|
|
void testStatus(){
|
|
if(analogRead(SAMPLE) > 0.01){
|
|
STATUS = true;}
|
|
else{
|
|
Serial.println("Can't identify music, sending pulse...");
|
|
pinMode(PULSE, OUTPUT);
|
|
digitalWrite(PULSE, HIGH);
|
|
if(analogRead(SAMPLE) > 0.01){STATUS = true;}
|
|
else{STATUS = false;}
|
|
}
|
|
digitalWrite(PULSE, LOW);
|
|
pinMode(PULSE, INPUT);
|
|
}
|