//micDetectA.ino int MIC = 5; // cds connected int val = 0; int sound = 0; float MAX = 900.0; float MIN = 300.0; void setup (){ pinMode(LED, OUTPUT); Serial.begin(115200); } void loop(){ val = analogRead(MIC); sound = int( (MAX-float(val))/(MAX-MIN)*255.0 ); if(sound > 255) { sound = 255; } else if (sound < 0) { sound = 0; } if( Serial.available() > 0 ){ Serial.write(sound); Serial.read(); } }