Question
Asked April 18 2015

Community Question

Has anybody used, or know if these can be used with the EZ-B v4? And if do, how do they connect? These flex/bend sensors would be great if they worked with the EZ-B and EZ-Builder. Not much information on power, but they can be used on analog or digital (although I think analog would be better).

Flex / bend sensors

User-inserted image
April 19 2015
The idea I had for these was to place them inside of a rubber or foam bumper of a tracked or wheeled robot, and act as a bumper sensor. When the bumper touches something like a door frame when the robot is turning, the flexing of the sensors would would trigger a script to stop motors, reverse, and re-track to avoid the obstical with a script.

These apparently work with Arduino, so they should work with an EZ-B.
June 12 2015
Love the tutorial vid and that makes sense for specific animatronic things. However, and I apologize if I missed this in another thread, I was hoping to utilize the ADC ports to operate flex sensors in this sort of function:

http://www.instructables.com/id/Arduino-Wireless-Animatronic-Hand-1/

I tested it out with the Arduino and it does what I want it to do, I just dont know how to "map" in the script the adc flex sensor input to the real time output of servo control.

My hope is to use ADC 0-4 to control servos on D0-4 repsectively on the EZ-B4. The other issue I am having is using the MPU6050 variables to control servos as well.

I have some ability with circuits and assembly, but I have the programming skills equivalent to just learning that the strings on my shoes keep them on, next year I hope to learn to tie them...

Again I apologize if these question have been answered elsewhere.
DJ Sures
Synthiam
June 12 2015
That's easy - if you know how to do it in complicated C++ Arduino, then you can certainly do it even easier in EZ-Builder:D . Here's how...

1) Add a new EZ-Script control
- Project
- Add Control
- Scripting
- EZ-Script

2) Paste in this code

Code:


:loop

Servo(d0, getadc(adc0))
Servo(d1, getadc(adc1))
Servo(d2, getadc(adc2))
Servo(d3, getadc(adc3))
Servo(d4, getadc(adc4))

sleep(100)

goto(loop)


*Note: you may have to add a multiplier of sort to the GetADC() for each of the positions to dial in your accuracy. As you may have seen with your Arduino setup, the resister values on the flex sensor determine the accuracy and voltage being returned.
June 13 2015
Thank you DJ! I am very proficient with copy and paste:) This makes me so happy, I've spent months reading how to books in arduino trying to figure out this I2c and wifi thing to no real avail. I can get the circuits to read right with meters but seldom get the code to operate correctly. (impatient with paying work getting in the way I guess), then I saw your creation and fell in love with it. A heartfelt thanks to you and your team.

What would the multiplier you speak of look like?
June 14 2015
@artchas... analog values are from 1 to 255...servo positions are from 1 to 180, so you would use a "multiplier" to convert them to a servo position... The multiplier in this case is 0.7058... You would multiply all your analog readings by .7058 and that would covert them to a servo position from 1 to 180....

Code:


:loop
$adc0= Round(getadc(adc0) *.7058,0)
$adc1= Round(getadc(adc1) *.7058,0)
$adc2= Round(getadc(adc3) *.7058,0)
$adc3= Round(getadc(adc3) *.7058,0)
$adc4= Round(getadc(adc4) *.7058,0)

Servo(d0, $adc0)
Servo(d1, $adc1)
Servo(d2, $adc2)
Servo(d3, $adc3)
Servo(d4, $adc4)

sleep(100)

goto(loop)
June 14 2015
Thank you Richard for the explanation!

So literally a mathematical function is in place. I see. Hypothetically I could then use this same concept to acquire and apply reading from a accelerometer for servo control as well?
I will look at the SC32 already in the EZB script and see how that is called for reading when I get time and see if I can figure that out. I am guessing I would need to use the add control function for the MPU6050, then set up a script that tells it to read that (similar to above with the exception that I would use the Hex address X or Y variables) and then assign that variable to a servo...? Am I in the ball park?

I see that the MMA7455 under I2C is already set to control servos in the settings. I will look at that too.

Thank you again