An oscilloscope is a device that allows you to see an electronic signal so that it appears as a waveform. Traditional oscilloscopes work by amplifying a signal to control the position of a dot on the y-axis (vertical axis) of a cathode-ray tube (CRT) while a time-base mechanism sweeps left to right on the x-axis, and then flips back when it reaches the end. These days, CRTs have largely been replaced by digital oscilloscopes that use liquid-crystal displays (LCDs), but the principles remain the same.
This project reads values from an analog input (a microphone) and sends them over a USB cable to a computer, which is programmed through an Arduino interface board to display those values as waveforms. As the signal changes, so does the shape of the waveform. As oscilloscopes go, this one is not going to win any prizes for accuracy or speed, but it is kind of fun and will display waveforms up to about 1 kHz.
Adapted from S. Monk, 30 Arduino Projects for the Evil Genius, 2nd Ed., McGraw-Hill Education, 2013
Things You Will Need
||Arduino Uno or Leonardo||Adafruit: 50 or 849
Sparkfun: DEV-11021 or DEV-11286
|C1||1||220 nF capacitor||Digikey: 445-2849-ND
|C2, C3||2||100 μF electrolytic capacitor||Sparkfun: COM-00096
|R1, R2|| 2
||1 MΩ 0.25-W resistor||Digikey: S1MHCT-ND
||1 kΩ 0.25-W resistor||Digikey: S1kHCT-ND
||5.1V zener diode|| Sparkfun: COM-10301
||Solderless breadboard||Adafruit: 64
|-||Set of jumper wires||Adafruit: 758
- A computer to program the Arduino
- A USB-type A-to-B lead (as used for printers)
Fig. 1 shows the schematic diagram for this project, while Fig. 2 shows the breadboard layout.
1. Set up the hardware
Assemble the hardware according to the schematic diagram. Notice that there are two parts to the circuit. R1 and R2 are high-value resistors that "bias" the signal going to the analog input to 2.5V. These resistors are just like a voltage divider.
The capacitor C1 allows the signal to pass without any direct current (DC) component to the signal (alternating current, or AC, mode in a traditional oscilloscope). C1 can be connected either way around.
R3, R4, C2, and C3 just provide a stable reference voltage of 2.5V. The reason for this is so that your oscilloscope can display both positive and negative signals. C2 and C3 are polarized, so they must be connected the correct way around or they are likely to be damaged. As with LEDs, on polarized capacitors, the positive lead is longer than the negative lead.
One terminal of your test lead is fixed at 2.5V, so any signal on the other lead will be relative to that. A positive voltage will mean a value at the analog input of greater than 2.5V, and a negative value will mean a value at the analog input of less than 2.5V. The diode D1 will protect the analog input from accidental overvoltage.
Fig. 3 shows the completed oscilloscope.
2. Install and run the software
Make sure your computer has the Arduino software installed on it. Connect your Arduino board to your computer using the USB lead.
The software (sketch) for this project is short and simple (see Fig. 4). Its only purpose is to read the analog input and blast it out to the USB port as fast as possible.
To run this software, you first need to install some software called Processing. Processing is the natural partner for writing computer applications that communicate with an Arduino. It is available for Windows, Mac, and LINUX, and can be downloaded from www.processing.org.
Once Processing is installed, run it. Then open the file scope.pde, and click the Play button to run it. A window like Fig. 5 should appear.
3. Test the oscilloscope
The easiest way to test the oscilloscope is to use the one readily available signal that permeates most of our lives, and that is the hum from the electrical service. Home electricity oscillates at 50 or 60 Hz (depending on where you live in the world), and every electrical appliance emits electromagnetic radiation at this frequency. To pick it up, all you have to do is touch the test lead connected to the analog input, and you should see a signal similar to that of Fig. 5. Try waving your arm around near any electrical equipment, and see how the signal changes.
Once you have verified that your oscilloscope is working, play around with different sounds, and notice what happens to the waveform.