You are on page 1of 2

// Includes the noise filter library available at https://github.

com/sebnil/Moving-
Avarage-Filter--Arduino-Library-
#include <MovingAvarageFilter.h>

MovingAvarageFilter movingAvarageFilter1(20);
MovingAvarageFilter movingAvarageFilter2(20);
MovingAvarageFilter movingAvarageFilter3(20);
MovingAvarageFilter movingAvarageFilter4(20);
boolean check1 = false;
boolean check2 = false;
boolean check3 = false;
boolean check4 = false;

void setup() {
pinMode(0, INPUT);
pinMode(1, INPUT);
pinMode(2, INPUT);
pinMode(3, INPUT);
}

void loop() {

float input1 = analogRead(0);


float output1 = movingAvarageFilter1.process(input1); //input processing to filter
noise
if (output1 < 500 ) { // you can change this parameter to fine tune the sensitivity
if (!check1) {
tone(12, 440);
check1 = !check1;
}
}
if (output1 >800) { // you can change this parameter to fine tune the sensitivity
if (check1) {
noTone(12);
check1 = !check1;
}
}

float input2 = analogRead(1);


float output2 = movingAvarageFilter2.process(input2); //input processing to filter
noise
if (output2 < 500 ) { // you can change this parameter to fine tune the sensitivity
if (!check2) {
tone(12, 660);
check2 = !check2;
}
}
if (output2 >800) { // you can change this parameter to fine tune the sensitivity
if (check2) {
noTone(12);
check2 = !check2;
}
}

float input3 = analogRead(2);


float output3 = movingAvarageFilter3.process(input3); //input processing to filter
noise
if (output3 < 500 ) { // you can change this parameter to fine tune the sensitivity
if (!check3) {
tone(12, 880);
check3 = !check3;
}
}
if (output3 >800) { // you can change this parameter to fine tune the sensitivity
if (check3) {
noTone(12);
check3 = !check3;
}
}

float input4 = analogRead(3);


float output4 = movingAvarageFilter4.process(input4); //input processing to filter
noise
if (output4 < 500 ) { // you can change this parameter to fine tune the sensitivity
if (!check4) {
tone(12, 1240);
check4 = !check4;
}
}
if (output4 >800) { // you can change this parameter to fine tune the sensitivity
if (check4) {
noTone(12);
check4 = !check4;
}
}

You might also like