Hello, i am new to Arduino programming but i need to develop a pseudo code and working program for a voice operated door lock using a servo motor and voice recognition module V3 and Arduino Uno board.
Any help given is kindly appreciated.
Thank you
Do you have the sample programs working?
And to add to what @Paul_KD7HB said, I would recommend splitting your project into two parts at least:
Voice operated door lock
- Door lock using a servo
- Voice recognition module
Yes, the project is using the Voice recognition module to identify speakers. And a servo motor to drive the lock.
yes i have a program to help train the voice recognition module.
You are well on your way. What do you need help with?
i need help making a code to run the servo motor from 0 to 180 degrees and vice versa. this must happen when i say lock or open through the voice recognition module's microphone.
There must be lots of example code that will help with that. Have you considered that your servo will eat of lots of power while doing nothing?
i hadn't put that into consideration(servo motor consuming power when doing nothing)
This there anyway you think i can overcome this issue?
Not that I know of. That is why you don't see automatic door locks with servos.
well i am new here and this is amazing for me to get some knowledge with you guys.
thanks
Thank you for that.
Start with the servo sweep example, in the Arduino IDE file>examples>servo>
thank you
For specific help, post the code, using code tags. Tell us what you expect to happen and what happens instead.
#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
/**
Connection
Arduino VoiceRecognitionModule
2 -------> TX
3 -------> RX
*/
VR myVR(2, 3); // 2:RX 3:TX, you can choose your favourite pins.
uint8_t records[7]; // save record
uint8_t buf[64];
//int lock = 6;
//int unlock = 7;
#define onRecord (0)
#define offRecord (1)
void printSignature(uint8_t *buf, int len)
{
int i;
for (i = 0; i < len; i++) {
if (buf[i] > 0x19 && buf[i] < 0x7F) {
Serial.write(buf[i]);
}
else {
Serial.print("[");
Serial.print(buf[i], HEX);
Serial.print("]");
}
}
}
void printVR(uint8_t *buf)
{
Serial.println("VR Index\tGroup\tRecordNum\tSignature");
Serial.print(buf[2], DEC);
Serial.print("\t\t");
if (buf[0] == 0xFF) {
Serial.print("NONE");
}
else if (buf[0] & 0x80) {
Serial.print("UG ");
Serial.print(buf[0] & (~0x80), DEC);
}
else {
Serial.print("SG ");
Serial.print(buf[0], DEC);
}
Serial.print("\t");
Serial.print(buf[1], DEC);
Serial.print("\t\t");
if (buf[3] > 0) {
printSignature(buf + 4, buf[3]);
}
else {
Serial.print("NONE");
}
Serial.println("\r\n");
}
void setup()
{
/** initialize */
myVR.begin(9600);
myservo.attach(6); // attaches the servo on pin 6 to the servo object
Serial.begin(115200);
Serial.println("Elechouse Voice Recognition V3 Module\r\nControl LED sample");
// pinMode(lock, OUTPUT);
// pinMode(unlock, OUTPUT);
if (myVR.clear() == 0) {
Serial.println("Recognizer cleared.");
} else {
Serial.println("Not find VoiceRecognitionModule.");
Serial.println("Please check connection and restart Arduino.");
while (1);
}
if (myVR.load((uint8_t)onRecord) >= 0) {
Serial.println("onRecord loaded");
}
if (myVR.load((uint8_t)offRecord) >= 0) {
Serial.println("offRecord loaded");
}
}
void loop()
{
int ret;
ret = myVR.recognize(buf, 50);
if (ret > 0) {
switch (buf[1]) {
case onRecord:
// digitalWrite(lock, HIGH);
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
// delay(500);
// digitalWrite(lock, LOW);
break;
case offRecord:
// digitalWrite(unlock, HIGH);
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
// delay(500);
// digitalWrite(unlock, LOW);
break;
default:
Serial.println("Record function undefined");
break;
}
/** voice recognized */
printVR(buf);
}
}
i need to generate a psuedo code for that program. but i dont understand what 0x19 or 0x7F mean
Bytes with values > 0x19 and < 0x7F happen to be printable ASCII characters.
I also don't understand how exactly a voice recognition module works. How does the stored data on the module work with commands from the Arduino to move an object, for my case a servo motor?
It appears that you did not write this code, and are really just trying to understand what it does.
Is this for a class assignment or project?