Members | Sign In
MOVI User Community Forum > MOVI Projects
avatar

Voice Activated Electric Easel for Quadriplegic- Trouble with Arduino code within Res = 1 to control Linear Actuator

posted Jan 16, 2017 23:39:26 by MICHAELGAHAGAN
Hello, using Movi connected to Mega and a ServoCity Dual Motor Controller for voice activated control of linear actuator, also using stepper motors. Cannot get working (works without Movi triggering) actuator code to work within a Movi Res. Voice portion is recognized by Movi- believe problem is that code within the Res. I suspect that timing might be a problem but I'm quite the ignorant on many fronts. Code snippet below- I pasted the Loop code into Res 1 for the Sample beginner LightSwitch sketch. Any help WAY appreciated!

///////////////

int LeftDistance = 0;

void setup() {
pinMode(10, OUTPUT);// connects to servo signal input to ServoCity dual motor (linear actuator) controller.
}

void loop() {
if (LeftDistance < 20) { //value of 20 gets about 1/4 inch of actuator movement
digitalWrite(10, HIGH);
delayMicroseconds(1000); // 1000 piston goes out; 2000 piston goes in;
digitalWrite(10, LOW);
LeftDistance = LeftDistance + 1;
}
}

mg
page   1
4 replies
avatar
GeraldFriedland said Jan 17, 2017 04:19:44
Without seeing the entire code, if you copied the above code right within after the res==1, the motor will exactly do one step after sentence 1 is recognized. The good news is that there is an easy fix: replace the "if (LeftDistance < 20)" with a "while if (LeftDistance < 20)". So your code should look like this:

void loop() {
   signed int res=recognizer.poll(); // Get result from MOVI, 0 denotes nothing happened
   if (res==1) {                     // Sentence 1.
     while (LeftDistance < 20) { //value of 20 gets about 1/4 inch of actuator movement 
       digitalWrite(10, HIGH); 
       delayMicroseconds(1000); // 1000 piston goes out; 2000 piston goes in; 
       digitalWrite(10, LOW); 
       LeftDistance = LeftDistance + 1; 
     } 
   }
  // ... 
}
[Last edited Jan 17, 2017 04:20:47]
avatar
MICHAELGAHAGAN said Jan 17, 2017 23:49:37
Thanks for the response Gerald- still can't get it to work. Will continue to beat my head against the wall in effort to solve, and after donating more blood- will get back to you. This is for my paralyzed brother in law who paints with a mouthstick. He'll be using voice commands to make easel- painting go up/down, left/right, in/out. Have built the structure and got it work, manually triggered. Once I've got this going I'll share project details on your forum- it's pretty sweet (and a noble cause to boot!).
mg
avatar
MICHAELGAHAGAN said Jan 19, 2017 00:20:45
Gerald- got it going (5 out of 6 movements, 1 to go). thanks for your input sir!
mg
avatar
GeraldFriedland said Jan 20, 2017 02:31:31
Congrats! I am looking forward to seeing a video!
Login below to reply: