joystick mid value is 527 max is 1023 and min is 0
I changed it to 515 in code because the number that I got was neative on the transmitter side and 255 on the receiver side ( yeah for some reason when it gets a negative value it goes staight to 255...
Here is the updated code (not working)
Transmitter:
#include <SoftwareSerial.h>
int ROT ;
SoftwareSerial HC12(10, 11);
void setup() {
Serial.begin(9600);
HC12.begin(9600);
}
void loop() {
int ROT = analogRead(A0);
ROT = map(ROT , 515 , 1023 , 1200 , 1800) ;
Serial.println(ROT);
HC12.write(ROT);
delay(100);
}
Reciever :
#include <Servo.h>
#include <SoftwareSerial.h>
int ROT ;
int Speed;
int Rotor = 0 ;
int Rotor1 = 1 ;
Servo myServo;
SoftwareSerial HC12(10,11);
void setup() {
myServo.attach(6);
HC12.begin(9600);
Serial.begin(9600);
}
void loop() {
while ( HC12.available()>0) {
ROT = HC12.read();
Serial.println(ROT);
}
myServo.write(ROT);
delay(100);
}
P.S. I think that I shoud mention again that this is an 120 degree servo motor