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

Files at this revision

API Documentation at this revision

Comitter:
ned
Date:
Fri Dec 13 02:10:53 2013 +0000
Commit message:
First working version that reads the sensor and moves the "limb".

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
LCD_fonts.lib Show annotated file Show diff for this revision Revisions of this file
Servo.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Fri Dec 13 02:10:53 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/C12832_lcd/#8f86576007d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_fonts.lib	Fri Dec 13 02:10:53 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/LCD_fonts/#d0b7d7bf1f56
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Fri Dec 13 02:10:53 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Fri Dec 13 02:10:53 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#849c0c0f2769
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 13 02:10:53 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file