Arduino Projects Experiments Part6
Arduino Projects Experiments Part6
The Theremin
104
The electronic sounds generated by the Arduino are wired to a simple transistor
amplifier. Pay close attention to the 100 uF electrolytic capacitors orientation
(shown on the Fritzing diagram) to prevent damage to the Arduino. Also, the NPN
transistors pinout for either a 2N3904 or S9013 electronic component is shown on
the Fritzing diagrams breadboard. The mini 8 speaker color wire leads must be
connected correctly (as shown in Figure 12-2) in order for the audio electronic
sounds to be heard through it.
Circuit Theory
The 2N3904 or S39013 NPN transistor amplifies or increases the audio signal created
by the Arduino. The transistor has an amplification value called gain used to determine the volume of an electrical signal. A typical gain value engineers use in
designing simple amplifiers like this one is 100. The mini 8 speaker can be wired
directly to pin D9 with a reasonable amount of volume, but the simple transistor
amplifier increases the sound by a factor of 100, making the Theremin sound louder.
The block diagram in Figure 12-5 shows the building blocks and the electrical signal
flow for the Theremin. A Fritzing software circuit schematic diagram of the Theremin
is shown in Figure 12-6. As a reminder, circuit schematic diagrams use electrical
symbols for electronic components and are abbreviated drawings of Fritzing
diagrams.
110
Figure 13-3. R2 and Vout measured and displayed on the Serial Monitor
Example 13-1. The Arduino Ohmmeter sketch
/*
Arduino Ohmmeter
*/
// set up pins on Arduino
int analogPin = 0;
//
int raw = 0;
//
int Vin = 5;
//
float Vout = 0;
//
float R1 = 1000;
//
float R2 = 0;
//
float buffer = 0;
//
void setup()
{
Serial.begin(9600);
// Set up serial
}
void loop()
{
raw = analogRead(analogPin);
if(raw)
{
116