[Solved]Joystick remote


hey, i'm hacking old remote w/ uno , hc05 bluetooth module control uno w/ hc06. i'm not sure on how transfer x , y joystick positions uno. can them uno in car
but don't know how separate them in car. here remote code:
code: [select]

int joypin1 = 0;
int joypin2 = 1;
int value1 = 0;
int value2 = 0;
int outcome1;
int outcome2;
void setup() {
  serial.begin(9600);
}

int treatvalue(int data) {
  return (data / 37) - 1;
}

void loop() {
  value1 = analogread(joypin1);

  outcome1 = treatvalue(value1);

  delay(100);

  value2 = analogread(joypin2);

  outcome2 = treatvalue(value2);

  delay(100);

  if (outcome1 < 0) {
    outcome1 = 0;
  }
  if (outcome2 < 0) {
    outcome2 = 0;
  }
  serial.print(outcome1);
  serial.print(outcome2);
}

and robots code:
code: [select]

char serialread;
int motoraval;
int motorbval;
void setup() {
  serial.begin(9600);
}

void loop() {
  while (serial.available() > 0) {
    serialread = serial.read();
    if (serialread > 5) {
      motoraval = serialread;
    }
    else {
      motorbval = serialread;
    }
    delay(200);
  }
}

please help.

quote
but don't know how separate them in car.
the values send going between 0 , 26. suppose first 13 , second 8. sending "138". now, knowing sent , got, can see how separate values. but, if 223? 22 , 3 or 2 , 23?

i think can see need send kind of delimiter between values. may less obvious need send 1 between packets, too.


Arduino Forum > Using Arduino > Programming Questions > [Solved]Joystick remote


arduino

Comments