sample test program with Ax12

Dependencies:   AX12 C12832_lcd SerialHalfDuplex mbed

Revision:
0:0069ce266807
Child:
1:58dae564e9ff
diff -r 000000000000 -r 0069ce266807 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 20 06:36:14 2014 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "AX12.h"
+#include "C12832_lcd.h"
+
+AnalogIn pot1(p19);
+C12832_LCD lcd;
+
+/*******************************/
+/********mapping function*******/
+/*convert old range to new range*/
+/*******************************/
+double  map(double val, double b_min, double b_max, double a_min, double a_max)
+{
+    return (val - b_max) * (a_min - a_max) / (b_min - b_max) + a_max;
+}
+
+int main()
+{
+    AX12 myax12 (p9, p10, 2); //for LPC1768
+    int deg;
+    while (1) {
+        lcd.cls();//clear screen
+        lcd.locate(40,3);//set locate
+        lcd.printf("!Hello Ax12!");
+        lcd.line(0, 13, 128, 13, 1);//draw a line
+        deg=(int)map(pot1*10.0, 0.0, 10.0, 0.0, 300.0 );//convert range
+        lcd.locate(0,15);//set locate
+        lcd.printf("Pos:%g,Temp:%g,Volt%g",myax12.GetPosition(),myax12.GetTemp(),myax12.GetVolts());
+        myax12.SetGoal(deg);    // set ax12 go to deg
+        wait(0.1);
+    }
+}
\ No newline at end of file