Hey guys,
I'm really new to this.. Have been trying quite a few basic projects and i was trying to combine a few of them together.
The microphone works with the Piezo or the servo but when i combined them all up, the servo just does not seem to work.
And is there any possibility to re-adjust the sensitivity of the servo so it does not react to every noise detected ?
if there are more tutorials about this in the web pls do kindly state below
Cheers,
K
#include <Servo.h>
Servo MyServo;
int ServoPin = 9;
int piezo = 8;
int duration = 250;
int notes[] =
{392,493,523,0,0,523,0,0,392,493,523,0,0,523,0,0,523,493,440,0,0,440,0,0,392,392,440,0,0,440,0,0,440,392,349,0,0,349,0,0,349,440,392,0,0,392,0,0,392,493,523,0,0,523,0,0,392,493,523,0,0,523,0,0}; //stand by me verse by ben.e.king
void setup() {
Serial.begin(300);
MyServo.attach(ServoPin);
pinMode(piezo, OUTPUT);
}
void loop() {
int sensorValue = analogRead(0);
Serial.println(sensorValue);
for (int i = 0; i < 64; i++)
{tone(piezo, notes[i], duration);
delay (duration);
}
for (int i = 64; i>0; --i)
{tone(piezo,notes[i],duration);
}
sensorValue = map(sensorValue,0,250,0,180);
MyServo.write(sensorValue);
}


