仕事に関しては、さまざまな自由度のプラットフォームを管理した経験があるため、最初にしたかったのは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-プラットフォームを構築する
プラットフォームの組み立ては、次の順序で実行されます。
- プラットフォームのベースにワイヤをねじ込む。
- ベースへのサーボの取り付け;
- プラットフォームプラットフォーム上のワイヤの留め具の取り付け。
- サーボへの文字「G」の形のファスナーの取り付け。
まとめ
次の図に示すように、結果はプラットフォームのベースになります。 リードタイムは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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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 .
#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: 制御クラスのソースコード