Improving the project performance
I mentioned earlier that we were going to talk about the threshold value. In general, solutions for projects with analog read set the threshold value to 200
, but as you remember, we are using a value of 300
to ensure we are reading a clap, not background noise.
If you want to know more precisely the value of your clap's sound, then you can use the example script that the IDE provides us. To access this sketch, we must go to the File menu, then to Examples, and choose Basics. In that section, we will find the AnalogReadSerial sketch, as shown in Figure 7.10:
Selecting that menu option will open the AnalogReadSerial.ino
sketch:
void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(0); Serial.println(sensorValue); delay(1); }
The previous code introduces an instruction that we have not...