代码
int analogPin = A0; // int val = 0; // variable to store the value read int value = 0; #define ledPin 9 #define MIC_MAX 100 void setup() { Serial.begin(9600); // setup serial pinMode(ledPin, OUTPUT); } void loop() { val = analogRead(analogPin); // read the input pin Serial.print("MIC="); Serial.println(val); // debug value if (val > MIC_MAX) { digitalWrite(ledPin, HIGH); delay(5000); } else { digitalWrite(ledPin, LOW); } delay(100); }