Got the jaw of my robowaifu moving by purchasing an arduino sound sensor and a cheap usb stereo speaker.The tricky part was figuring out how to get her jaw microservo to move in response to sound, but it can be accomplished using the following Arduino IDE code (copied straight from the .ino file):
#include <Servo.h>
Servo myservo;
/*
LED1 should be lit, showing power. LED2 indicates sound input, and the sensitivity is adjusted by potentiometer.
There is a tiny screw on the blue potentiometer block that you can use for adjustment. Turning that
clockwise lowers the potentiometer value, while counter-clockwise raises the potentiometer value.
Use the potentiometer to adjust the Sound Sensor sensitivity. Turn the potentiometer
several rotations until you see the LED2 extinguish (or just faintly blink). This might be slightly greater than
500, if you are also watching Serial Monitor (inital adjustment), or, Serial Plotter (the latter is prefererd for observation).
Special thanks to user CRomer, for his input and hard work!
*/
int sensorAnalogPin = A0; // Select the Arduino input pin to accept the Sound Sensor's analog output
int sensorDigitalPin = 3; // Select the Arduino input pin to accept the Sound Sensor's digital output
int analogValue = 0; // Define variable to store the analog value coming from the Sound Sensor
int digitalValue; // Define variable to store the digital value coming from the Sound Sensor
int Led13 = 13; // Define servo port;
// When D0 from the Sound Sensor (connnected to pin 7 on the
// Arduino) sends High (voltage present), L will light. In practice, you
// should see LED13 on the Arduino blink when LED2 on the Sensor is 100% lit.
void setup()
{
myservo.attach(7); //attch
myservo.write(90);// move servo5 to center position -> 90°
Serial.begin(9600); // The IDE settings for Serial Monitor/Plotter (preferred) must match this speed
pinMode(sensorDigitalPin,INPUT); // Define pin 7 as an input port, to accept digital input
pinMode(Led13,OUTPUT); // Define servo5 as an output port, to indicate digital trigger reached
}
void loop(){
analogValue = analogRead(sensorAnalogPin); // Read the value of the analog interface A0 assigned to digitalValue
digitalValue=digitalRead(sensorDigitalPin); // Read the value of the digital interface 7 assigned to digitalValue
Serial.println(analogValue); // Send the analog value to the serial transmit interface
if(digitalValue==HIGH) // When the Sound Sensor sends signal, via voltage present, light up LED13 AND turn myservo
{
digitalWrite(Led13,HIGH);
myservo.write(40);
delay(40);
}
else
{
digitalWrite(Led13,LOW);
myservo.write(30);
delay(40);
}
delay(25); // Slight pause so that we don't overwhelm the serial interface
}
This is about as expedient a solution as I could find. Prior to this I was considering purchasing a Picotalk controller, but they cost $80+shipping. Whereas a micro-servo, sound sensor and Elegoo Mega 2560 (Arduino clone) costs as little as $20 and can be used in combination with many other devices (including a servo shield to drive six or seven other servos). I am currently in the process of designing a 'voice box' for these parts to fit inside, which will have a speaker-cone to improve functionality (hopefully I won't have to hold the sound sensor 5mm away from the speaker every time I want her jaw to move with her speech).
>===
-patched codetag
Edited last time by Chobitsu on 10/25/2020 (Sun) 10:32:40.