I took your advice and created an array for the three servos, but now I'm a bit lost on how I will choose the servo and then be able to use the switch command...
Help!..... =]
Like always, thanks in advance
Woehrlec
#include <Servo.h>
#include <NewSoftSerial.h>
#define N_SERVOS 3
Servo myServo [N_SERVOS];
const byte servoPin [N_SERVOS] = {7,8,9};
NewSoftSerial mySerial = NewSoftSerial(2,3);
int value = 0; // for incoming serial data
int value1 = 0;
int pos=0;
int orig = 5;
void setup() {
// initialize serial communication:
Serial.begin(9600);
Serial.print("Initalize Servo");
mySerial.begin(9600);
Serial.print("Servo Initalized");
for (int i = 0; i < N_SERVOS; ++i) {
myServo [i].attach (servoPin [i]);
}
}
void loop() {
if (mySerial.available() > 0) {
int inByte = mySerial.read();
value1 = map(value, 0, 9, 0, 180);
// do something different depending on the character received.
switch (inByte) {
case 'n': //North
servo_a.write(165);
break;
case 's': //South
servo_a.write(10);
break;
case 'o': //Original or neutral
servo_a.write(90);
break;
default:
// anyother character go to default
servo_a.write(90);
}
delay(15);
}
}