Stap 5: Code voor de analoge microfoon
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);