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
main.cpp
- Committer:
- ned
- Date:
- 2013-12-13
- Revision:
- 0:1fc648cdc764
File content as of revision 0:1fc648cdc764:
#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 ); }