An oscilloscope is a very handy device to have around for analyzing electrical signals that change over time. These signals may come from microphones (so you can look at the waves produced by music or voice) or from any other sensor you can connect electrically.

In the photo above, you can see a close-up of the oscilloscope screen, showing an 880 Hertz sine wave generated by our previous project, the Arduino Sine Wave Generator.

The parts for the oscilloscope are fairly simple, easing the construction considerably:

We have the 1.8 inch thin-film transistor LCD screen we used in the previous project, and Arduino Nano. a rotary encode (the same one as used in the previous project) and some Dupont ribbon cable for putting the other parts together.

The female ends of the ribbon cable fit nicely onto the pins of the LCD screen. The male ends fit into the holes in the Arduino Nano board, where they are then soldered in place:

LCD wiring table
LCD pin Color Arduino pin
VCC Red 3V3
CLK Black 13
SDA White 11
RS Gray 8
RST Purple 9
CS Blue 10

Feel free to use other colors if you like. What is important is which pins on the LCD are connected to which holes in the Arduino.

IMPORTANT NOTE: The VCC pin on the LCD screen must connect to the 3.3 volt hole in the Arduino Nano (the hole next to pin 13). Don't connect it to the VCC hole of the Arduino Nano, because that is 5 volts, and that is too much for the screen to handle. The LCD screen is meant to run on 3.3 volts only, no more.

The next step is to attach Dupont ribbon cable to the rotary encoder. The rotary encode is the input device that will let us navigate the computer menus on the LCD screen.

In the photo you can see the top left pin is connected to the bottom left pin using a length of purple ribbon cable. We have removed the connectors and stripped the ends of the wire before soldering it in place.

Also connected to the top left pin is a green wire. We have removed the female end and stripped it before soldering it in place. The male end will be soldered to the Arduino Nano later.

The top middle pin is soldered to the yellow wire, the top right pin is soldered to the orange wire, and the bottom right pin is soldered to the blue wire.

The photo above is a close-up of the rotary encoder, showing how the wires are soldered.

Rotary encoder wiring table
Encoder pin Color Arduino pin
Top left Green GND
Top middle Yellow A2
Top right Orange A3
Bottom right Blue Pin 3


The final steps are to solder the male ends of the encoder wires to the proper holes in the Arduino Nano, and to solder two extra wires (I used white and gray) to be our input connections, where the signal will come in. The gray wire is connected to any of the grounded places. I chose to bend the pin and solder it to the back of the Arduino Nano's ground hole where the brown Dupont wire came through, since we have already used up both of the convenient ground holes on the Nano. If you find it easier to connect the gray wire to either of the leftmost pins on the rotary encoder, that will do nicely, as they are (of course) connected to each other and to the Nano's other ground hole.

The white wire is connected to the A0 pin on the Nano. This is the analog pin where our signal comes in.

The photo above shows the oscilloscope connected to our Sine Wave Generator, which is set to produce a 440 Hz sine wave (in music, that is called an A, or A440). Note that I chose to use the same color scheme (white and gray) for the oscilloscope inputs as for the sine wave generator outputs, to make it easy to remember which wire is signal and which is ground. The sine wave had male outputs, so the oscilloscope has female inputs.

When we double the frequency to 880 Hertz, we get the A an octave above A440, and you can see that we get twice as many sine waves on the screen.

You can power the oscilloscope with a 3.3 volt battery if you like, just as we did with the sine wave generator. Just connect the battery to the 5 volt input hole of the Arduino Nano -- it will run just fine on the lower voltage. I generally don't bother with batteries, finding it more convenient to simply use the Nano's USB programming cable to power it. The photo above shows the two projects together in their quaint wooden boxes (feel free to use commercial plastic project boxes, or 3D printed cases, of course). A smoked-glass or other dark cover will hide imperfections and the LCD bezel, and only the text and lines will show through.

The photo above shows what you get when you use the rotary encoder to select the Trigger menu. The trigger is the green line on the screen, and rotating the encoder clockwise or counterclockwise adjusts the green line up or down. This has the effect of selecting the voltage at which the scan begins. When the signal voltage reaches the trigger setting, the oscilloscope starts recording samples.

The other main menu option is the samples per second setting. 

There are four options, 80  thousand samples per second, 40 thousand, 20 thousand, and 10 thousand.

The 80 thousand samples per second option really pushes the limits of the little computer, and it can't actually sample that fast, due to the overhead of interrupt handling, but it gets close. For the same reason, there is very little computing power left over for noticing changes to the rotary encoder settings, so some patience is required to even get out of that mode (of course you can always power it down or reset it, and it will come back in 40,000 samples per second mode).

As you can see in the photo above, when we samples at 20,000 samples per second, we see more of the waveform.

At 10,000 samples per second, we see even more, as shown above. The setting you choose will depend on the frequency of the incoming signal. These photos show 440 Hertz. At frequencies around 20,000 Hertz, you would select 40,000 samples per second, or 80,000, or else the waves would all seem to crowd together.

The source code for the oscilloscope can be found here.

The program has several parts, each in its own file. The menu system resides in the file RotaryMenu.h. The code that actually samples the voltages using the Analog to Digital Converter (ADC) inside the Nano is in ADC.cpp and its header file ADC.h. The code that uses the rotary encoder menu system to control the ADC is in the main file, NanoScope.ino.

This separation of function allows you to more easily use the ADC code or the menu code in other programs.

The oscilloscope uses the Adafruit_GFX and Adafruit_ST7735 libraries like the sine wave generator project does. The detailed instructions for loading and installing those libraries can be found there.