For front, you never turn the motors off after the pauze.
If the left doesn't vibrate as much as the right, then maybe the left distance is less than the right
Feel pretty stupid right now, sorry to have bothered you with this sloppy work...
Just tested the left and right with the old motor and they feel pretty similar.
looks like this motor is defective...
Will order another and go from there.
Keep you posted and thank you for your help!!
No problem
You use floats to do time-math with. DON'T!
Not kidding here, you need to use unsigned long variables because unsigned subtraction is KEY to the formulas that always works up to the longest elapsed time the variable can hold.
With millis() an unsigned long can measure 49.7-some DAYS.
Elapsed time = End time - Start time ---- every time, even past rollover/
Unrelated tip: use bytes instead of ints for small values like pin numbers and you save half of the RAM used.
Any progress?
Still waiting for the new motor...
Will update asap.
Did a little corrections on the debug lines but that was it.
Glued, the vibrator to the handle ( see picture ) what would be a clever way to cover that?
thought of some plastic and tape...
When in doubt, duct tape...
Make sure those dupont cables don't get dislodged.
Whatever you do, be sure to not interfere with the braking system of the walker.
Have you tried heat-shrink tubing or Sugru tape?
Would you cover the complete little board with that stuff?
Had my dad in today and he didn't really feel the vibrations that well.
I stuck them to a large body of material and I guess this is absorbing too much energy.
Will stick the new motor to the brake handle, see how that feels.
Yeah, that frame is a lot of mass for a tiny little piece of tungsten metal to put in motion.
The downside with the breaks is that it means the cables will be flexing a lot and there's a fairly big chance of your dad dislodging the PCB from the handle.
The new motor works!
Stuck them both to the brake handles and the vibrations are more clear, going to test the system with my dad tomorrow.
Did notice that if i walk towards a wall at a 45 degree angle the sensors do not fire.
Will fiddle some with the distances maybe that helps...
Hope he can walk with it, it's going to have a learning curve. ( He knows its a rudimentary system! )
The forum tanked my reply.
What can be wrapped in tape can be done more professionally.
Maybe use the walker tubing for heat sinking or add a strip of metal that is not insulated to carry heat away.
Nothing you can do in that case. Those ultrasonic devices work best at 90 degrees, anything less and the return signal starts to decrease in strengh
I like the way you think!
However it's a proof of concept kind of thing, so if tape works tape is fine.
He might not like the walker, might not be able to use it or he might not want to put in the work learning to use it.
I'm curious to see what happens.
So what sensor would be a better choice?
Is it a bug or a feature!
He might be able to use the 90 ish degrees thing to make 90 ish degrees turns when he encounters a corner in the hallway.
Stop near the end of the hallway then rotate till the side sensor fires..
You could use more than one ping sensor so that at least one gets a return.
If you have lines on the floor, line follower robot techniques might be used.
My "final" script ( maybe somebody can use it some day )
bool debug = 0;
const float left = 50.0;
const float right = 50.0;
const float front = 80.0;
const int trigleft = 6;
const int echoleft = 7;
const int trigright = 8;
const int echoright = 9;
const int trigfront = 10;
const int echofront = 11;
const int motorleft = 4;
const int motorright = 3;
unsigned long durationleft;
float distanceleft;
unsigned long durationright;
float distanceright;
unsigned long durationfront;
float distancefront;
void setup() {
pinMode(motorleft, OUTPUT);
pinMode(motorright, OUTPUT);
pinMode(trigleft, OUTPUT);
pinMode(echoleft, INPUT);
pinMode(trigright, OUTPUT);
pinMode(echoright, INPUT);
pinMode(trigfront, OUTPUT);
pinMode(echofront, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigleft, LOW);
delayMicroseconds(2);
digitalWrite(trigleft, HIGH);
delayMicroseconds(10);
digitalWrite(trigleft, LOW);
durationleft = pulseIn(echoleft, HIGH);
distanceleft = (durationleft * .0343) / 2;
delayMicroseconds(60);
digitalWrite(trigright, LOW);
delayMicroseconds(2);
digitalWrite(trigright, HIGH);
delayMicroseconds(10);
digitalWrite(trigright, LOW);
durationright = pulseIn(echoright, HIGH);
distanceright = (durationright * .0343) / 2;
delayMicroseconds(60);
digitalWrite(trigfront, LOW);
delayMicroseconds(2);
digitalWrite(trigfront, HIGH);
delayMicroseconds(10);
digitalWrite(trigfront, LOW);
durationfront = pulseIn(echofront, HIGH);
distancefront = (durationfront * .0343) / 2;
delayMicroseconds(60);
if (distanceleft < left) {
digitalWrite(motorleft, HIGH);
float pauzeleft = 8 * distanceleft;
delay(pauzeleft);
if (debug) {
Serial.print("Distanceleft: ");
Serial.println(distanceleft);
Serial.print("Delay: ");
Serial.println(pauzeleft);
Serial.println("left on");
}
digitalWrite(motorleft, LOW);
} else {
digitalWrite(motorleft, LOW);
Serial.println("left off");
}
if (distanceright < right) {
digitalWrite(motorright, HIGH);
float pauzeright = 8 * distanceright;
delay(pauzeright);
if (debug) {
Serial.print("Distanceright: ");
Serial.println(distanceright);
Serial.print("Delay: ");
Serial.println(pauzeright);
Serial.println("right on");
}
digitalWrite(motorright, LOW);
} else {
digitalWrite(motorright, LOW);
Serial.println("right off");
}
if (distancefront < front) {
digitalWrite(motorleft, HIGH);
digitalWrite(motorright, HIGH);
float pauzefront = 8 * distancefront;
delay(pauzefront);
if (debug) {
Serial.print("Distancefront: ");
Serial.println(distancefront);
Serial.print("Delay: ");
Serial.println(pauzefront);
Serial.println("front on");
}
digitalWrite(motorleft, LOW);
digitalWrite(motorright, LOW);
} else {
digitalWrite(motorleft, LOW);
digitalWrite(motorright, LOW);
Serial.println("front off");
}
delay(60);
}
So are you declaring success?