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...