thanks for the valuable input i was able to make it work; but i have a new problem and i don't know how to solve it
special thanks to PaulS
i am trying to control three different servos using three different pots
so i wrote the code assigning three different pots and servos, but i am unable to setup the individual links between the pots and the servo
when i upload the following codes, and when one pot is turned all three servos turn, which is not what i am looking for
could somebody explain how i can set up a wireless link between, for eg. analog pin 0 and PWM pin 9 etc
thanks a lot
sender end
int potPin_0 = 0;
int potPin_1 = 1;
int potPin_2 = 2;
void setup()
{
//Create Serial Object (9600 Baud)
Serial.begin(9600);
}
void loop()
{
int val_0 = map(analogRead(potPin_0), 0, 1023, 0, 9);
Serial.print(val_0);
delay(50);
int val_1 = map(analogRead(potPin_1), 0, 1023, 0, 9);
Serial.print(val_1);
delay(50);
int val_2 = map(analogRead(potPin_2), 0, 1023, 0, 9);
Serial.print(val_2);
delay(50);
}
receiver end
#include <Servo.h>
//Define Pins
int servoPin_0 = 8;
int servoPin_1 = 9;
int servoPin_2 = 10;
//Create Servo Object
Servo orangeServo;
Servo wristServo;
Servo gripperServo;
void setup()
{
//Start Serial
Serial.begin(9600);
//Attaches the Servo to our object
orangeServo.attach(servoPin_0);
wristServo.attach(servoPin_1);
gripperServo.attach(servoPin_2);
delay(500);
}
void loop()
{
while( Serial.available() == 0);
int data_0 = Serial.read() -'0';
int pos_0 = map(data_0, 0, 9, 0, 180);
pos_0 = constrain(pos_0, 0, 180);
//Turn the servo
Serial.print(pos_0);
orangeServo.write(pos_0);
while(Serial.available()>0);
Serial.read();
while( Serial.available() == 0);
int data_1 = Serial.read() -'0';
int pos_1 = map(data_1, 0, 9, 0, 180);
pos_1 = constrain(pos_1, 0, 180);
//Turn the servo
Serial.print(pos_1);
wristServo.write(pos_1);
while(Serial.available()>0);
Serial.read();
while( Serial.available() == 0);
int data_2 = Serial.read() -'0';
int pos_2 = map(data_2, 0, 9, 0, 180);
pos_2 = constrain(pos_2, 0, 180);
//Turn the servo
Serial.print(pos_2);
gripperServo.write(pos_2);
while(Serial.available()>0);
Serial.read();
}