серво + микрофон
- Войдите на сайт для отправки комментариев
Чт, 12/11/2015 - 12:15

есть скетч и схема сборки.
#include <Servo.h> // Controlling a servo position using a potentiometer (variable resistor) // by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> Servo myservo; // create servo object to control a servo int potpin = 0; // analog pin used to connect the potentiometer int val = 90; // variable to read the value from the analog pin int RtPin = 3; int LtPin = 4; int Right = 0; int Left = 0; void setup() { Serial.begin(9600); pinMode(RtPin, INPUT); pinMode(LtPin, INPUT); myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { Right = digitalRead(RtPin); Left = digitalRead(LtPin); if (Right == 1 && val > 10) {val -= 20;} if (Left == 1 && val < 170) {val += 20;} // delay(100); myservo.write(val); // val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) // val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180) // myservo.write(val); // sets the servo position according to the scaled value Serial.print("Left = " ); Serial.print(Left); Serial.print(" Right = "); Serial.println(Right); Serial.print(" val = "); Serial.println(val); delay(15); // waits for the servo to get there }
Уверен, что проблема в усилителе микрофона. Ибо отсутствует.
Даже при нормальном, усиленном сигнале с микрофона результат работы будет весьма относителен. Дело в том, что электретные микрофонные капсюли в большинстве случаев не имеют узкой направленности, что важно для вашего применения.
Для устйчивого ослеживания направления, нужно будет доработать акустическое оформление капсюлей..