I have some problem in my code i don't know what the value of the first servo keeps mix with the third and the fifth I don't know why
......
Here's my receiver code :-----
#include <RCSwitch.h>
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
RCSwitch myswitch = RCSwitch();
void setup() {
servo1.attach(9);
servo2.attach(10);
servo3.attach(11);
servo4.attach(12);
servo5.attach(13);
Serial.begin(9600);
myswitch.enableReceive(0);
}
void loop() {
if (myswitch.available()){
int value = myswitch.getReceivedValue();
switch (value) {
case 0 ... 180:{
servo1.write(value);
Serial.println(value);
delay(100);}
break;
case 500 ... 680:{
int value2=value-500;
servo2.write(value2);}
break;
case 1000 ... 1180:{
int value3=value-1000;
servo3.write(value3);}
break;
case 1500 ... 1680:{
int value4=value-1500;
servo4.write(value4);}
break;
case 2000 ... 2180:{
int value5=value-2000;
servo5.write(value5);}
break;
}
}
}
When i receive the first value the servo change to it after while it's changes by his own to another value .
Tho i have all this ranges the servo is still not stable..
#include <RCSwitch.h>
RCSwitch myswitch = RCSwitch();
int pot1 = A0;
int pot2 = A1;
int pot3 = A2;
int pot4 = A3;
int pot5 = A4;
void setup() {
Serial.begin(9600);
myswitch.enableTransmit(10);
}
void loop() {
int pott1 = analogRead(pot1);
pott1 = map(pott1,0,3023,0,180);
int angle1 = pott1;
myswitch.send(angle1, 10);
delay(100);
int pott2 = analogRead(pot2);
pott2 = map(pott2,0,3023,0,180);
int angle2 = pott2+500;
myswitch.send(angle2, 10);
delay(100);
int pott3 = analogRead(pot3);
pott3 = map(pott3,0,1023,0,180);
int angle3 = pott3+1000;
myswitch.send(angle3, 10);
delay(100);
int pott4 = analogRead(pot4);
pott4 = map(pott4,0,1023,0,180);
int angle4 = pott4+1500;
myswitch.send(angle4, 10);
delay(100);
int pott5 = analogRead(pot5);
pott5 = map(pott5,0,1023,0,180);
int angle5 = pott5+2000;
myswitch.send(angle5, 10);
delay(100);
}
And i attached my simulation..
And an example of what happened
..............
The servo suppose to change through it's potentiometer but i guess the other potentiometers affects the value of the servo too ...
Like when i send 180 in the first potentiometer the servo give me 180 and change to 9 , 10 then go back to 180 and so on
You need to determine what numeric values the receiver is receiving.
Print them to the monitor.
Run some tests noting the values make just one servo move, and which values unexpectedly make multiple servos move.