HerkuleX-HelloWorld

Dependencies:   herkulex mbed

This herkulex library is based on DongBu Robot documentation and protocol.

http://dasarobot.com/guide/herkulexeng.pdf

/media/uploads/passionvirus/mbedandherkulex_i.png /media/uploads/passionvirus/range.png

Files at this revision

API Documentation at this revision

Comitter:
passionvirus
Date:
Mon Jan 14 16:25:33 2013 +0000
Parent:
0:50f3665aec00
Child:
2:7004e3d0281f
Commit message:
Change example code

Changed in this revision

herkulex.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
--- a/herkulex.lib	Mon Jan 14 07:50:04 2013 +0000
+++ b/herkulex.lib	Mon Jan 14 16:25:33 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/passionvirus/code/herkulex/#e6873d42df32
+http://mbed.org/users/passionvirus/code/herkulex/#f737e5c70115
--- a/main.cpp	Mon Jan 14 07:50:04 2013 +0000
+++ b/main.cpp	Mon Jan 14 16:25:33 2013 +0000
@@ -1,21 +1,37 @@
 #include "mbed.h"
 #include "herkulex.h"
 
+// set serial port and baudrate, (mbed <-> HerculexX)
 Herkulex sv(p9, p10, 115200);
-DigitalOut led(LED1);
 
 int main() 
 {   
-    wait(1);
+    sv.clear(0xFD);
     sv.setTorque(0xFD, TORQUE_ON);
+    
     while(1) 
-    {
-        led=1;
-        sv.movePos(0xFD, 1002, 100, SET_MODE_POS, SET_LED_GREEN_ON);
-        wait(3);
+    {       
+        // POS Mode, +159.8 Degree, 100*11.2ms = 1120ms, Green LED On
+        sv.movePos(0xFD, 1002, 100, GLED_ON);
+        wait(5);
         
-        led=0;       
-        sv.movePos(0xFD, 21, 100, SET_MODE_POS, SET_LED_BLUE_ON);
-        wait(3);
+        // POS Mode, -159.8 Degree, 100*11.2ms = 1120ms, Blue LED On
+        sv.movePos(0xFD, 21, 100, BLED_ON);
+        wait(5);
+
+        // TURN Mode, CCW Turn, Green LED On
+        sv.turn(0xFD, 1023, GLED_ON);
+        wait(5);
+        
+        // TURN Mode, CW Turn, Blue LED On        
+        sv.turn(0xFD, -1023, BLED_ON);
+        wait(5);
+        
+        // POS Mode, 0 Degree, 100*11.2ms = 1120ms, Red LED On
+        sv.movePos(0xFD, 512, 100, RLED_ON);
+        wait(5);
+        
+        // Clear error status
+        sv.clear(0xFD);
     }
 }