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

Committer:
passionvirus
Date:
Mon Jan 14 16:25:33 2013 +0000
Revision:
1:ef646c52e08f
Parent:
0:50f3665aec00
Child:
2:7004e3d0281f
Change example code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
passionvirus 0:50f3665aec00 1 #include "mbed.h"
passionvirus 0:50f3665aec00 2 #include "herkulex.h"
passionvirus 0:50f3665aec00 3
passionvirus 1:ef646c52e08f 4 // set serial port and baudrate, (mbed <-> HerculexX)
passionvirus 0:50f3665aec00 5 Herkulex sv(p9, p10, 115200);
passionvirus 0:50f3665aec00 6
passionvirus 0:50f3665aec00 7 int main()
passionvirus 0:50f3665aec00 8 {
passionvirus 1:ef646c52e08f 9 sv.clear(0xFD);
passionvirus 0:50f3665aec00 10 sv.setTorque(0xFD, TORQUE_ON);
passionvirus 1:ef646c52e08f 11
passionvirus 0:50f3665aec00 12 while(1)
passionvirus 1:ef646c52e08f 13 {
passionvirus 1:ef646c52e08f 14 // POS Mode, +159.8 Degree, 100*11.2ms = 1120ms, Green LED On
passionvirus 1:ef646c52e08f 15 sv.movePos(0xFD, 1002, 100, GLED_ON);
passionvirus 1:ef646c52e08f 16 wait(5);
passionvirus 0:50f3665aec00 17
passionvirus 1:ef646c52e08f 18 // POS Mode, -159.8 Degree, 100*11.2ms = 1120ms, Blue LED On
passionvirus 1:ef646c52e08f 19 sv.movePos(0xFD, 21, 100, BLED_ON);
passionvirus 1:ef646c52e08f 20 wait(5);
passionvirus 1:ef646c52e08f 21
passionvirus 1:ef646c52e08f 22 // TURN Mode, CCW Turn, Green LED On
passionvirus 1:ef646c52e08f 23 sv.turn(0xFD, 1023, GLED_ON);
passionvirus 1:ef646c52e08f 24 wait(5);
passionvirus 1:ef646c52e08f 25
passionvirus 1:ef646c52e08f 26 // TURN Mode, CW Turn, Blue LED On
passionvirus 1:ef646c52e08f 27 sv.turn(0xFD, -1023, BLED_ON);
passionvirus 1:ef646c52e08f 28 wait(5);
passionvirus 1:ef646c52e08f 29
passionvirus 1:ef646c52e08f 30 // POS Mode, 0 Degree, 100*11.2ms = 1120ms, Red LED On
passionvirus 1:ef646c52e08f 31 sv.movePos(0xFD, 512, 100, RLED_ON);
passionvirus 1:ef646c52e08f 32 wait(5);
passionvirus 1:ef646c52e08f 33
passionvirus 1:ef646c52e08f 34 // Clear error status
passionvirus 1:ef646c52e08f 35 sv.clear(0xFD);
passionvirus 0:50f3665aec00 36 }
passionvirus 0:50f3665aec00 37 }