![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Move a limb and read its position with a flex sensor.
Dependencies: C12832_lcd LCD_fonts Servo USBDevice mbed
I wanted to create the simplest limb as part of a course. It involves a limb that moves driven by a stepper motor. The angle of the limb is read by using a flex sensor.
The first time it worked:
https://www.dropbox.com/s/9l5ynsjg8zdynk8/Video%20Dec%2003%2C%209%2048%2034%20AM.mov
Schematic:
https://www.dropbox.com/s/szzpks89ne8evxe/simple%20limb%20schematic.png
Diff: main.cpp
- Revision:
- 0:1fc648cdc764
diff -r 000000000000 -r 1fc648cdc764 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 13 02:10:53 2013 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +#include "USBSerial.h" +#include "Servo.h" +#include "C12832_lcd.h" + +void FlexSensorReport( void ); + +C12832_LCD lcd; +//USBSerial serial; +//Serial pc( USBTX, USBRX ); +AnalogIn flex( p19 ); +Servo myservo( p22 ); + +int main() +{ + while(1) + { + for(float i=0; i<100; i++) + { + myservo = i/100.0; + FlexSensorReport(); + wait(0.1); + } + for(float i=100.0; i>0; i--) + { + myservo = i/100.0; + FlexSensorReport(); + wait(0.1); + } + + } +} + + +void FlexSensorReport( void ) +{ + float f = flex.read(); + lcd.cls(); + lcd.locate( 0, 3 ); + lcd.printf( "%02f %02f %02f", f, f*10.0, f*100.0 ); + //serial.printf( "f = %02f %02f %02f \r\n", f, f*10.0, f*100.0 ); +} \ No newline at end of file