Voici un tuto expliquant comment brancher un HP sur un arduino nano dédié ( non relié a myrobotlab ) afin d’avoir une synchronisation parfaite entre la bouche du inmoov et les paroles.
Comment cela fonctionne ?
C’est tres simple , chaque son envoie une impulsion sur une entrée analogique de l’arduino qui actionne instantanément le servo.
Ce qu’il faut :
–> un arduino nano
–> un petit HP avec ampli
————————————————————————————————–
les branchements :
http://img15.hostingpics.net/pics/832542branchementparoleinmoov.jpg
————————————————————————————————–
le script arduino :
// code pour Parole du Inmoov !! le son du PC doit etre suffisemment fort
#include <Servo.h>
// Définition des constantes
#define VOICEservoPin 6 // pin du servo bouche
#define VOICEHPpin 3 // pin du HP
//déclaration des variables
Servo VOICEmyservo;
int VOICESecondDetection = 1; //
int VOICEval = 0; // variable to store the read value
int VOICEi = 0;
int VOICEpos = 55; // variable to store the servo position
int VOICEBoucheStatus = 0;
int VOICEActionBouche = 0;
unsigned long timeofdetect;
char VOICEdelayFlag = 0;
unsigned long VOICEdelay = 1;
unsigned long VOICEtime;
void setup()
{
analogReference(EXTERNAL);
pinMode(VOICEservoPin, OUTPUT);
Serial.begin(9600);
VOICEmyservo.attach(VOICEservoPin);
VOICEmyservo.write(55);
}
void loop()
// debut VOICE
{ if (VOICEdelayFlag == 0) {
VOICEval = analogRead(VOICEHPpin);
if (VOICEval < 630 || VOICEval > 680 ) // recherche valeur entre 665 et 680 ( a ajuster si besoin )
{
VOICEBoucheStatus = 1; // bouche fermée
}
else // tant que
{
VOICEi++; // la valeur entre 630 et 680 est pas trouvée
}
if (VOICEi >= VOICESecondDetection)
{
VOICEi = 0;
VOICEBoucheStatus = 0;
}
}
if (VOICEBoucheStatus == 0 && VOICEActionBouche == 0) {
if (VOICEdelayFlag == 0) {
VOICEmyservo.write(95);
VOICEtime = millis();
VOICEdelayFlag = 1;
}
delay(40); //1
if (VOICEtime + VOICEdelay < millis() and VOICEdelayFlag == 1) {
VOICEmyservo.write(55);
VOICEtime = millis();
VOICEdelayFlag = 2;
}
delay(40); //2
if (VOICEtime + VOICEdelay < millis() and VOICEdelayFlag == 2) {
VOICEActionBouche = 1;
VOICEtime = millis();
VOICEdelayFlag = 0;
}
}
if ((VOICEBoucheStatus == 1 && VOICEActionBouche == 1) or VOICEdelayFlag == 3)
{
if (VOICEdelayFlag == 0) {
VOICEdelayFlag = 3;
VOICEmyservo.write(55);
VOICEtime = millis();
delay(40); // 3
}
if (VOICEtime + VOICEdelay < millis()) {
VOICEActionBouche = 0;
VOICEtime = millis();
VOICEdelayFlag = 0;
}
}
// fin de VOICE
}
-
This topic was modified 8 years, 3 months ago by ╔ Jack ╗.
-
This topic was modified 8 years, 3 months ago by ╔ Jack ╗.
-
This topic was modified 8 years, 3 months ago by ╔ Jack ╗.