Arduinoの3度マニピュレーター

Eduオンラインオークションで安全に注文できるArduinoプラットフォームに関する多くの興味深い記事があります。 このプラットフォームについては、インターネット上に多くのモジュールと記事がありますので、毎日の生活に役立つとは限りませんが、何か面白いことをしたかったのです。

画像





仕事に関しては、さまざまな自由度のプラットフォームを管理した経験があるため、最初にしたかったのは6度プラットフォーム(Stewart Platform)でしたが、残念ながら4つのサーボドライブだけが来たので、まずは3度プラットフォームを作成します。



ツールと材料



したがって、このユニットを作成するには、次のコンポーネントが必要です。

命名 数量
Arduino Mega 1個
HXT900サーボ 3個
合板 1個
5V電圧レギュレータ 1個
ペーパークリップ 3個
ワイヤーホルダー 3個
USBコード 1個
電源 1個
接続線 13個
スティラコサウルス 1個




オークションでのボードとコントローラーArduino Mega Kitの価格は50ドルからです。 中国からのサーボの購入では、問題もないはずです。1個のコストは約2ドルです。 合板は、国内または店舗で見つけることができます。 職場での3つのペーパークリップ。 最も難しいのは、スティラコサウルスを入手することです。通常、これらの種の動物は郵便局または子供用の店で見ることができます。



プラットフォーム製造



プラットフォームを製造する主なタスクは、プラットフォームのベースとプラットフォーム自体を合板から切り取ることです。 コントロール要素は、円の内側に120度の角度で配置されます。



1ステップ-のこぎり


プラットフォームのサイズは10x10 cm、プラットフォーム自体は8x8 cmで、プラットフォーム自体は正方形のままでもかまいませんが、便宜上、三角形がカットされています。 のこぎりは、サポートの取り付けの場所で作られます。



2ステップ-穴あけ


穴あけには、最初に3つの部分に分割された円を描く必要があります。 120度未満の光線では、サーボを適用する必要があります。また、穴あけのポイントをマークする必要があります。



取り付け方法に応じて、完成したマーキングに従って穴を開けます。 ハーネスで固定する場合(最適なオプション)、穴の直径は4 mmでなければなりません。 ワイヤーで固定する場合(私の場合のように)、直径2 mmの穴で十分です。



3ステップ-アンカレッジの準備


ステープル以外の留め具は見つかりませんでした(職場でのデモの後、別のオプションが提案されました)。 クリップは、文字「G」の形で作成する必要があります。これは、サーボドライブに固定され、プラットフォームプラットフォームのマウントに挿入されます。



職場では、ステープルの代わりに、Trex 450ヘリコプターのボールマウントを使用するように申し出られました(すでに中国から注文されています)。 このタイプのマウントを使用すると、プラットフォームの構造がより強固になります。



ステップ4-プラットフォームを構築する


プラットフォームの組み立ては、次の順序で実行されます。





まとめ


次の図に示すように、結果はプラットフォームのベースになります。 リードタイムは1時間です。

画像



回路組立



接続するには、Arduino Webサイトの公式ドキュメントに記載されている方法が最初に使用されました。 複数のサーボを接続する場合、電源は十分ではないため、5V電圧レギュレーターを介して3台のドライブに個別に「電源を入れる」ことをお勧めします( 詳細な接続説明 )。



Arduinoに3つのサーボを接続すると、電力が不足し、保護が作動します。 ブレッドボードのスタビライザーを介した3つのドライブの接続を次の図に示します。

画像



Arduinoからの制御は、ボードからの1、2、3アナログ出力(アナログピン)を使用して実行されます。 私の場合、電源もボードから接続されています。 接続の例を図に示します。

画像

左から右へ:青-5V、黄色-「接地」、赤-ドライブ1、黒-ドライブ2、黄色ドライブ3



接続図全体の形式は次のとおりです。

画像



Arduinoプログラミング



プラットフォームは、Arduinoが提供するシリアルポートを介してコンピューターから制御されます。 ポートの操作はシリアルライブラリを使用して実行され、サーボの制御はSoftwareServoライブラリを使用して実行されます。



シリアルポートからコマンドを解析するには、Cで次の構造を使用します。

struct _set_pos_cmd_t

{

char cmd;

int pos1;

int pos2;

int pos3;

};



typedef _set_pos_cmd_t set_pos_cmd_t;




* This source code was highlighted with Source Code Highlighter .








struct _set_pos_cmd_t

{

char cmd;

int pos1;

int pos2;

int pos3;

};



typedef _set_pos_cmd_t set_pos_cmd_t;




* This source code was highlighted with Source Code Highlighter .












したがって、3つの整数位置が示されます。 コマンドバイトも示されています。この場合、コントローラーに位置を書き込むコマンドのコードは0xC1です。



サーボの位置はupdate_positions関数を使用して設定されます。この関数は、コマンドからの値をサーボシャフトの回転角の値にマッピングします。

void update_positions()

{

int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM);

myservo1.write(val);

val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM);

myservo2.write(val);

val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM);

myservo3.write(val);

delay(5);

SoftwareServo::refresh();

}




* This source code was highlighted with Source Code Highlighter .








void update_positions()

{

int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM);

myservo1.write(val);

val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM);

myservo2.write(val);

val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM);

myservo3.write(val);

delay(5);

SoftwareServo::refresh();

}




* This source code was highlighted with Source Code Highlighter .












Arduinoの最終プログラム


#include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  1. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  2. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  3. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  4. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  5. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  6. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  7. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  8. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  9. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  10. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  11. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  12. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  13. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  14. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  15. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  16. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  17. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  18. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  19. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  20. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  21. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  22. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  23. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  24. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  25. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  26. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  27. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  28. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  29. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  30. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  31. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  32. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  33. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  34. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  35. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  36. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  37. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  38. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  39. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  40. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  41. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  42. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  43. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  44. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  45. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  46. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  47. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  48. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  49. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  50. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  51. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  52. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  53. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  54. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  55. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  56. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  57. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  58. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  59. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  60. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  61. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  62. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  63. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  64. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  65. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  66. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  67. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  68. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  69. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  70. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  71. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  72. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  73. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  74. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  75. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  76. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  77. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  78. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







  79. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .







#include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .











管理プログラム



3段階のプラットフォーム管理プログラムはC#で記述されており、元の形式では簡略化されています。

画像



プラットフォーム管理プログラムの最新バージョンは次の形式を取りました。

画像



UPD: 制御クラスのソースコード



実装ビデオ







ご清聴ありがとうございました!




All Articles