Paso 5: Código para el micrófono analógico
function readSoundSensorValue() { var buffer = new upmMicrophone.uint16Array(128); var len = myMic.getSampledWindow(2, 128, buffer); if (len) { var thresh = myMic.findThreshold(threshContext, 30, buffer, len); myMic.printGraph(threshContext); if (thresh) console.log("Threshold is " + thresh); v.saveValue(thresh); if(thresh>50 && thresh<150) showNormalLCD(); if(thresh>=150) showLCD(); if(thresh<50) showSleepLCD(); } } setInterval(readSoundSensorValue, 1000);