HowTo-Color (8) / Hacking Electronics / Simon Monk / 236-3 / Chapter 9
232
Hacking Electronics The “calibrate” function takes an initial reading of the acceleration on the X-axis, after waiting 200 milliseconds for the accelerometer to turn on properly. void calibrate() { delay(200); // give accelerometer time to turn on levelX = analogRead(xPin); }
How to Make a Software VU Meter The mic module you used in the section “How to Make an FM Bug” is also perfectly suited for use with microcontrollers like the Arduino. Figure 9-22 shows the module with pins attached to it and pushed into the analog connector strip of the Arduino. The mic module can be used to measure the sound level and write a number of “*”s to the Serial Monitor to indicate the loudness of the sound (Figure 9-23).
Figure 9-22 Attaching a mic module to an Arduino
Figure 9-23 The Serial Monitor as a VU meter
09-ch09.indd 232
1/3/13 3:47 PM