Demo

Description

In this assignment, I used my final project system which is introduced in Final Project. This interface visualizes a part of the functionality of the system (input device). The input sensors of this system are microphone, which can perceive the sound of the environment. When designing the interface, I regard the strength of signal received by the microphone as the trigger mechanism of button. To be specific, the "microphone button" is triggered when the perceived sound exceeds 350 decibels.

Implementation

For interface Implementation, I involved a new library. To be specific, I added this in code:

#include "MegunoLink.h"
                    

Then, I read the sound value sensed by microphone

int soundValue = 0; //create variable to store many different readings
                        for (int i = 0; i < 32; i++){ //create a for loop to read 
                          soundValue += analogRead(sound_sensor);  
                        } //read the sound sensor
                      
                        soundValue >>= 5; //bitshift operation 
                        Serial.println(soundValue); //print the value of sound sensor
                      
                      
                      //if a value higher than 350 is registered, the button will be triggered
                        if (soundValue > 350) { 
                          ……
                        }
                      

The plot drawing part is shown below (Send data to plot):

XYPlot Plot; // see: https://www.megunolink.com/documentation/plotting/xy-plot-library-reference/
                        Plot.Clear();
                        for(int i=0; i< NumberOfMeasurements; ++i)
                        {
                          long TimeSinceStart = MeasurementTime[i] - MeasurementTime[0];
                          Plot.SendData("Button", TimeSinceStart, Measurement[i]);
                        }