26. • Arbotix-Mボード上のLEDを光らせる.
26
void setup() {
// initialize the digital pin as an output.
pinMode(0, OUTPUT); // Pin 0 maps to the USER LED on the ArbotiX Robocontroller.
}
void loop() {
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
28. • サーボモータのLEDを光らせる.
28
#include <ax12.h> //include the ArbotiX DYNAMIXEL library
const int SERVO_ID = 1; // Identifier of the servo
const int BLINK_TIME = 1000; //time foe each LED to be on
void setup()
{
dxlInit(1000000); //start dynamixel library at 1mbps to communicate with the servos
}
void loop()
{
dxlLEDOn(SERVO_ID);
delay(BLINK_TIME);
dxlLEDOff(SERVO_ID);
delay(BLINK_TIME);
}
29. • サーボモータのIDを変える.
29
#include <ax12.h>
int id_old, id_new;
void setup(){
dxlInit(1000000); //start dynamixel library at 1mbps to communicate with the servos
id_old = 1;
id_new = 2;
ax12SetRegister(id_old, AX_ID, id_new); // IDの書き換え
}
void loop(){
}
この sketch を実行するときには,ボードには1個だけの
サーボモータが接続されている状況にしておくこと.
ID番号は0から253まで使用可能.254はブロードキャストのIDとして特別に使用される.
書き換えがうまくいったことの確認のために,
ここに,新IDのモータを動かすか
新IDのモータのLEDを点滅させる
コードなどを書くといいかもしれない.
このスケッチを実行後に別の作業を行う場合は,
トラブル回避のため
スケッチ「Arbotix-Mボード上のLEDを光らせる.」
をボードに書き込んでおくこと.