DesignSpark Electrical Logolinkedin
Menu Search
Ask a Question

How noisy are you?

Oh! please keep quiet!!! Arduino based noise logger with servo drawing machine. How to shut your friend's mouth? The orange part is the temperature recorder.

Parts List

Product
See more products

How noisy you are!

Arduino sound, light and more.

I am so glad to have you here. Today I am going to share the Arduino experience, How noisy you are!

Do you have any friends around you who are very noisy?

Suitable advice with a gentle voice is vital to get things done. This device could be a good partner for a persuasive speech. Its LED chain will demonstrate the amplitude of voice. Whoever controls their voice well develops better speech. Use this device wisely and it may help you in hunting down more success.

Low body temperature is a sign of lack of confidence which you may not be aware of when delivering your speech. Likewise, our temperature sensor gives a response to your own temperature, giving a better understanding of your body's sense toward speech.

Hardware Part

This project requires Arduino Mega with Arduino IDE. In addition to a Standard Servo. Finally, we display our temperature results on a paper wheel with a pen plotting the graph.

A slow motor is recommended in this demo, it is the key to bringing the temperature recorder’s life.

The above image is attached below.

DesignSpark PCB 8.1 is the software we used to print and create the board.

More useful techniques can be followed in these further tutorials. 

 DesignSpark PCB 8.1 is an extremely easy tool when dealing with PCB design. It provides a 3d display which is very user-friendly.

Mechanical software- a 3D CAD software.

It is really easy to use and has lots of useful user information at this link.

The following is the 3D printers main part, it is the most vital part of the temperature recorder.

Software Part

We are now including the servo as an interrupt option.

We use constants due to us confirm of no changing part; mostly are the pins setting, Boolean and analog pin, etc.

Here we use pins 22-27,28-52 for the LEDs.

We used a relay to bound the motor for continuous motion at pin 8.

We have used two interrupt pins as the Mega has 6 interrupt pins.

There are three states for controlling the tri light LED.
One state controls the servo on/off.

#include <Servo.h>
#include <math.h>                 //for temperature

const int B = 4275;               // B value of the thermistor
const int R0 = 100000;            // R0 = 100k     
 
const byte ledPin = 23;           //tri light
const byte ledPin2 = 27;          //tri light
const byte ledPin3 = 25;          //tri light
const byte interruptPin = 2;      //interrupt
const byte interruptPin2 = 21;    //interrupt

const byte MotorPin = 8;          //motor
volatile byte state = HIGH;       //tri light       
volatile byte state1 = LOW;       //tri light       
volatile byte state2 = LOW;       //tri light       
volatile byte state3 = LOW;       //Servo  
void high(int pin)                //LED ON     
{ digitalWrite(pin, HIGH); delay(10); }
void low(int pin)                 //LED OFF  
{ delay(10);digitalWrite(pin, LOW); }
// Define the pins to which the servo and sensor are connected.
const int pinServo = 3;
const int potentiometer = 0;
const int pinSound = A0;
const int pinangle = A1;
const int pintemp = A2;
int precition=1024;
int Baseprecition=0;
int add=0;
int mi=0;
int degree=0;
// Use a Servo object to represent and control the servo.
Servo AServo;
int thresholdValue = 400;

Here is the vital instructor.

We must set up all the pins we concerned as an interrupt or as an output.

If we didn’t set them up, the program still works yet the result may not be as expected. An interrupt mode we choose pinMode

(interruptPin, INPUT_PULLUP);// this is not part of the programe

to control the interrupt. We attach the interrupt pin with a debounced button. The pin Mode could be set up easily via a  loop or you can define them one by one. One by one is not a bad choice due to less correction and feel free to skip pins. In other words, it is case-oriented for every pin defined.

void setup()
{
   AServo.writeMicroseconds(1500);  // set servo to mid-point
  pinMode(MotorPin, OUTPUT);
   pinMode(ledPin, OUTPUT);
    pinMode(ledPin2, OUTPUT);
     pinMode(ledPin3, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
    pinMode(interruptPin2, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
    attachInterrupt(digitalPinToInterrupt(interruptPin2), blink2, CHANGE);

  for (int ok=22;ok<52;ok+=2){pinMode(ok,OUTPUT);}
  
   pinMode(22, OUTPUT);
    pinMode(24, OUTPUT);
     pinMode(26, OUTPUT);
      pinMode(28, OUTPUT);
       pinMode(30, OUTPUT);
        pinMode(32, OUTPUT);
         pinMode(34, OUTPUT);
          pinMode(36, OUTPUT);
           pinMode(38, OUTPUT);
            pinMode(40, OUTPUT);
             pinMode(42, OUTPUT);
              pinMode(44, OUTPUT);
               pinMode(46, OUTPUT);
                pinMode(48, OUTPUT);
                 pinMode(50, OUTPUT);
                  pinMode(52, OUTPUT);

    // Tell the Servo object which pin to use to control the servo.

    AServo.attach(pinServo);
Serial.begin(115200);
    // Configure the angle sensor's pin for input signals.
    pinMode(potentiometer, INPUT);
}

Here is the main function.

We activate the pins of LEDs and motor via the HIGH and LOW command.

The integer hello is a function that accumulates the level of noise of the sound sensor through the analogRead.

void loop()
{
   digitalWrite(ledPin, state);
   digitalWrite(ledPin2, state1);
   digitalWrite(ledPin3, state2);
   digitalWrite(MotorPin, state3);


    int sensorValue = analogRead(pinSound)+analogRead(pinangle);
    // Read the value of the angle sensor.
  //  int sensorPosition = analogRead(potentiometer);
 int hello=0;
  
 

We use the thresholdValue as an initial set up and the sensorValue as the main dependence factor of turning the led ON and OFF.

the add is ++

and mi is --

if(sensorValue > thresholdValue)    {
  int LLLEEEDDD=22;
  
  high(LLLEEEDDD);
  LLLEEEDDD+=2;hello+=add;//0
  if(sensorValue > thresholdValue+hello)    {
      high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//1
    if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//2
      if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//3
        if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//4
          if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//5
            if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//6
              if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//7
                if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//8
                  if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//9
                    if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//10
                      if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//11
                        if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//12
                          if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//13
                            if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  LLLEEEDDD+=2;hello+=add;//14
                              if(sensorValue > thresholdValue+hello)    {  high(LLLEEEDDD);  hello+=add;               //15                                              
                              }low(LLLEEEDDD);LLLEEEDDD-=2;  hello-=mi;
                            }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
                          }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
                        }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
                      }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
                    }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
                  }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
                }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi; 
              }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
            }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
          }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
        }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
      }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
    }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
  }low(LLLEEEDDD);LLLEEEDDD-=2;hello-=mi;
    



      Serial.println(sensorValue);
   
    }hello-=mi;

Finally the servo part.

The servo is controlled by state3 in an if condition command.

The servo is linked to pin4

Here is the function below.

    if(state3==LOW){
      digitalWrite(4, state3);        
 
     delay(15);}
     else if(state3==HIGH){
       digitalWrite(MotorPin, state3);
       digitalWrite(4, state3);
    int a = analogRead(2);

    float R = 1023.0/a-1.0;
    R = R0*R;

    float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15; // convert to temperature via datasheet

    Serial.print("temperature = ");
    Serial.println(temperature);
      
     //int sensorValue = analogRead(pinSound)+analogRead(pinangle);

   
   float shaftPosition = map(temperature, Baseprecition, precition, 1550 , degree);
 

    // Use the Servo object to move the servo.
    
    AServo.writeMicroseconds(shaftPosition);

   delay(15);
     }
}

Here are 2 interrupt functions blink and blink2.

Interrupt, is a useful function, it is named ISR( interrupt service routine), interrupt handler, in some textbooks.

blink is to control the tri light led on and off, and also the independent variables.

void blink() {

    if(state==HIGH){
      thresholdValue = 400;
 Baseprecition=0;
         precition=40;
      degree=2000;
  state = LOW;
  state1=LOW;
  add=50;
  mi=50;
state2=HIGH;}
  else  if(state2==HIGH){
         thresholdValue = 300;
 Baseprecition=0;
         precition=40;
 state = LOW;
 degree=2000;
 add=50;
 mi=50;
  state2=LOW;
  state1=HIGH;}
   else if(state1==HIGH){
         thresholdValue = 200;
         Baseprecition=0;
         precition=40;
         degree = 2000;
  state = HIGH;
  add=50;
  mi=50;
  state2=LOW;
  state1=LOW;}
}
void blink2() {
state3 = !state3;

  
  
}

 

Future Development

So what is next? Maybe a portable earthquake machine?


The future is invisible but you can make it happen by yourself.


Enjoy the fun of programming.

 

Downloads

Brian0925 has not written a bio yet…

Comments

August 6, 2019 11:00

nice project brian enjoyed following it