loading

This video demonstration with source code is an example of analog signal graphing. The project uses an Arduino Mega 2560 and UNO R3 2.8 TFT Touch Screen to display two analog signals as line and bar graphs. One signal is a photo resistor and the second is an audio sample from an Adafruit Electret Microphone Amplifier with Adjustable Gain module. The audio signal is graphically displayed twice; once in the center using a line graph and also on the bottom with a bar graph. The top graph represents the photo resistor signal.

Touching the screen pauses the graph and opens a menu to adjust setting for the graphs. You can change the color and direction of each graph.

Step 1: Download Essential Libraries and Copy the Source Code

Download and install the source code and libraries using the link below. These are needed to interface with the UNO R3 2.8 TFT Touch Screen.

https://github.com/dmainmon/Arduino-TFT-Touch-Screen-Analog-Graphing

You need to unzip and copy the contents of the libraries folder into the Arduino libraries directory: on windows it is usually \Documents\Arduino\libraries

Watch the video demonstration for more information.

Step 2: Connect Analog Sensors to Arduino Mega 2560

For this project a photo resistor is used for one analog signal. An Adafruit Electret Microphone Amplifier with Adjustable Gain module is used for the second analog signal.

You can view the picture above to see how the connections are made between the Mega and the sensors. Note: there is an extra resistor above the photo resistor that is not being used.

The UNO R3 2.8 TFT Touch Screen covered most of the ports on the Arduino UNO so I used a Mega for this project. The microphone module required 3v -5v and recommended using the less noisy 3v channel on the Arduino. However, the touch screen covered both 3v and 5v ports. So, instead I used digital output 53 as a power source and connected a 220 ohm resistor between the power source and the microphone module. I used a 220 ohm resistor because I just happened to have one on my breadboard. A potentiometer or a higher ohm resistor might work better. However, if you use different voltage or a different resistor, you may need to adjust the code so that the graph displays properly. Changing the strength of the signal will require the data be massaged otherwise the graph spikes won't appear at all (too low) or the whole screen will be filled with the graph (too high).

The microphone module has 3 wires: SIGNAL, GND, and VCC. The GND is connected to the extra GND port on the Arduino (next to pin 53 on my Mega). The signal is connected to analog pin 15 on the Mega.

The photo resistor has one end connected to ground and the other to analog pin 14 on the Mega.

Note: In retrospect, using pin 53 for power is not necessary. The Duino Mega has a 5v output opposite the ground. I am so new to Arduino that I did not know this at the time I wrote the instructable!

Step 3: Upload Sketch and Start Graphing

Once you compile and upload the sketch, the TFT display will begin drawing three graphs. The top graph represents the photo resistor signal and varies depending on light levels. You can easily spike this graph by covering the photo resistor with your finger.

The center graph represents the audio signal. This waveform is drawn as a line graph having a baseline (zero point) at the center of the waveform.

The bottom bar graph is also the audio signal except the data has been modified to flip all negative values positive. If you run the two graphs in the same direction you will see that any spike on the center graph (up or down) will result in an up spike on the bottom graph; a different way of representing the same data.

If you press on the screen a menu will appear with buttons for Top, Center, and Bottom. Below this is a Data Capture area that displays the data from the last touch event. This data can be used to calibrate the touch screen. By pressing on the edges of the display you can determine the raw min and max values for x and y. These values are used in the sketch code and can effect the accuracy of data returned from touch events.

If you press on one of the Top, Center, or Bottom buttons you will see the options for each graph. Here you can set the color of the graph and the direction.

Have fun and experiment with graphing analog signals!

<p>Does not appear to work..with instructions and libraries given here in...</p><p>Something is missing...</p>
<p>I uploaded new libraries to the github download. These new libraries should work. I found that the links to the adafruit libraries did not work. Sorry.</p>
<p>Got this thing working... and it looks as if it's a library issue.</p>
<p>New libraries added to the github download. The same as used in the project. Can't remember but it could be from MCU fried.</p><p><a href="https://github.com/dmainmon/Arduino-TFT-Touch-Screen-Analog-Graphing" rel="nofollow">https://github.com/dmainmon/Arduino-TFT-Touch-Scre...</a></p>
<p>Adafruit TFTLCD and GFX library downloaded from somewhere else may work for you..</p>
<p>Some have had issues with the standard libraries so I've included the libraries used in this project in the github download:</p><p><a href="https://github.com/dmainmon/Arduino-TFT-Touch-Screen-Analog-Graphing" rel="nofollow">https://github.com/dmainmon/Arduino-TFT-Touch-Scre...</a></p>
<p>How did you get the MEGA2560 to work with the display? I have everything setup correctly for my UNO R3, but all I get on the MEGA2560 connection is a white screen.</p><p>However, I can see the screen touches in the serial window within the Arduino IDE.</p><p>Any help would be greatly appreciated.</p>
<p>White screen normally means a wrong use of libraries or missing library definitions.</p>
<p>i don't found any sketch !</p>
<p>Do you know how to harvest the touch screen from an old iPhone? I've got a knackered old 3GS, but the screen's still fine.</p>
<p>short answer No, phone screens are nearly impossible (smartphones), I have one lying around - source google</p>
<p>Nice, minimum mhz few can grasp the electret to display the signal?</p>

About This Instructable

13,064views

138favorites

License:

Bio: Will write code for food. :) If you need help with any of your embedded Arduino applications please send me a message.
More by dmainmon:ArduCAM Mini ESP8266 Web Camera ESP8266-12E DHT Thermostat ESP8266 OLED Clock IoT Using AJAX 
Add instructable to: