📜 ⬆️ ⬇️

Three-power Arduino Manipulator

A lot of interesting articles are available on the Arduino platform, which can be safely ordered on the Ebay online auction. There are many modules and articles on the Internet for this platform, so I wanted to do something interesting, though not always useful in everyday life.
image


At work, there is experience in managing platforms with different degrees of freedom, so the first thing I wanted to do was a six-degree platform (Stewart Platform) , but unfortunately only four servo drives came, so first we will make a three-degree platform.

Tools and materials


So to build this unit we need the following components:
Renamingamount
Arduino mega1 PC.
Servo drive HXT9003 pcs.
Plywood1 PC.
5V Voltage Stabilizer1 PC.
Paper clip3 pcs.
Wire mount3 pcs.
USB Cord1 PC.
Power Supply1 PC.
Connecting wires13 pcs.
Styracosaurus1 PC.

')
The cost of the board and controller Arduino Mega Kit at auction ranges from $ 50. With the purchase of servos from China, too, there should be no problems, the cost of one piece is about $ 2. Plywood can be found in the country or in the store. Three paper clips at work. The most difficult thing is to obtain a crayfish, usually these species of animals can be seen at the post office or in the children's store.

Platform making


The main task of manufacturing the platform is to cut out the base of the platform and the platform itself from plywood. Control elements are placed inside the circle at angles of 120 degrees.

Step 1 - Sawing

Cutting out the base of the platform measuring 10x10 cm, as well as the platform itself measuring 8x8 cm. The platform itself can be left square, but for convenience the triangle was cut. Cuts are made in the place of fastening of the supports.

Step 2 - Drilling

For drilling, you must first draw a circle, divided into three parts. In the rays under 120 degrees it is necessary to attach the servos, as well as mark the points for drilling.

Drill out the holes according to the prepared marking depending on the method of fastening. For fastening with harnesses (best option), the holes should be 4 mm in diameter. In the case of wire fastening (as in my case) there will be enough holes with a diameter of 2 mm.

Step 3 - Preparing Mounts

There was nothing for fastening except the clips (after the demonstration at work another option was proposed). Clips must be made in the form of the letter "G", which is fixed on the servo, and inserted into the mount on the platform platform.

At work, I was offered instead of clips to use a ball mount from a Trex 450 helicopter (already ordered from China). With this type of attachment, the platform will be more rigid in construction.

4 Step - Build Platform

The platform is assembled in the following sequence:


Results

The result is a base platform, shown in the figure below. Runtime 1 hour .
image

Circuit assembly


To connect, the method described in the official documentation on the Arduino website was originally used. When connecting several servo drives, there is not enough power, so it is advisable to “power up” three drives separately via a 5V voltage regulator ( detailed connection description ).

In the case of connecting three servo drives on the Arduino, the power supply will be missed and the protection will be triggered. The connection of three drives through a stabilizer on a breadboard is shown in the figure below:
image

Control from the Arduino will be carried out using 1, 2, 3 analog outputs (Analog Pins) from the board. In my case, the power is also connected from the board. An example connection is shown in the figure:
image
where from left to right: blue - 5V, yellow - “ground”, red - drive 1, black - drive 2, yellow drive 3.

The entire wiring diagram is:
image

Arduino Programming


The platform is controlled from a computer via a serial port provided by Arduino. The port is handled by the Serial library, and servos are controlled by the SoftwareServo library.

To parse a command from a serial port, use the following structure in the C language:
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 .


Accordingly, three positions are indicated in integer form. The command byte is also indicated, in our case the command for writing positions to the controller is code 0xC1 .

Setting the positions of the servos is performed using the update_positions function, which maps the values ​​from the command to the values ​​of the angle of rotation of the servo shaft.
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 .


The final program for Arduino

#include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  1. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  2. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  3. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  4. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  5. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  6. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  7. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  8. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  9. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  10. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  11. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  12. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  13. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  14. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  15. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  16. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  17. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  18. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  19. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  20. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  21. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  22. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  23. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  24. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  25. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  26. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  27. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  28. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  29. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  30. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  31. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  32. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  33. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  34. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  35. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  36. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  37. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  38. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  39. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  40. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  41. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  42. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  43. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  44. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  45. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  46. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  47. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  48. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  49. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  50. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  51. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  52. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  53. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  54. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  55. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  56. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  57. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  58. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  59. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  60. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  61. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  62. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  63. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  64. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  65. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  66. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  67. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  68. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  69. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  70. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  71. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  72. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  73. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  74. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  75. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  76. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  77. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  78. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
  79. #include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .
#include <SoftwareServo.h> #define SET_CMD 0xC1 #define COMMAND_ERROR 0x01 #define FORMAT_ERROR 0x02 #define VALUE_MINIMUM 0 #define VALUE_MAXIMUM 4096 #define SERVO_MINIMUM 0 #define SERVO_MAXIMUM 90 SoftwareServo myservo1; SoftwareServo myservo2; SoftwareServo myservo3; int servo_position1 = 0; int servo_position2 = 0; int servo_position3 = 0; struct _set_pos_cmd_t { char cmd; int pos1; int pos2; int pos3; }; typedef _set_pos_cmd_t set_pos_cmd_t; void setup() { pinMode(13, OUTPUT); myservo1.attach(A0); myservo2.attach(A1); myservo3.attach(A2); Serial.begin(115200); } boolean readBytes( char *bytes, int count) { char data; for ( int counter = 0; counter < count; ++counter) { data = Serial.read(); bytes[counter] = data; } Serial.flush(); return true ; } void set_positions( char *data) { set_pos_cmd_t *command = (set_pos_cmd_t*)data; servo_position1 = command->pos1; servo_position2 = command->pos2; servo_position3 = command->pos3; } void update_positions() { int val = map(servo_position1, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo1.write(val); val = map(servo_position2, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo2.write(val); val = map(servo_position3, VALUE_MINIMUM, VALUE_MAXIMUM, SERVO_MINIMUM, SERVO_MAXIMUM); myservo3.write(val); delay(5); SoftwareServo::refresh(); } void loop() { int availableBytes = 0; char buffer[128]; if ((availableBytes = Serial.available()) > 0) { if (!readBytes(buffer, availableBytes)) { Serial.write(FORMAT_ERROR); } switch (buffer[0]) { case SET_CMD: set_positions(buffer); Serial.write(0xDA); break ; } } update_positions(); } * This source code was highlighted with Source Code Highlighter .


Management program


The three-step platform management program is written in C #, which in its original form had a simplified form:
image

The latest version of the platform control program took the form:
image

UPD: control class source code

Implementation video




Thanks for attention!

Source: https://habr.com/ru/post/126026/


All Articles