controller does not change values on the serial monitor

Hello all,

I have a lemon rx Dsm2 spectrum, pololu speedcontroler, and a arduino mega 2560. I was having trouble filling in the gaps and how to identify what numbers belong to what channel and so on. i need to be able to read the rx and print the values to the serial monitor. If someone could give some idea on how to go further i would be greatly appreciated.
thanks an advance.

9600 baud for serial, 115200 for serial1(input from RX) and serial2 (output to speed control).

Serial1 will receive the data for all channels in, as a message formatted like it says in the LemonRX UART specs. What i need to do is take that string of numbers (from serial1.read) and split it up, then enter each value into a variable. Then print all the variables to the computer via serial.print, then print all the variables to speed controllers via serial2.print.

In pseduocode it will look something like this:

setup(){
Setup serial (9600 baud);
Setup serial1(115200 baud);
Setup serial2(115200 baud);
}

loop(){
readserial1(); //calls "readserial1" function
serial.print('channel1');
serial.print("\t"); //prints a tab to space the values out
serial.print('channel2');
serial.print("\t");
etc...
serial.println('last channel');
sendspeedcontrolvalues(); //calls "sendspeedcontrolvalues" function
}

void readserial1(){
if serial1 is available{
read byte one;
save to 'channel1';
read byte two;
save to channel two;
etc...
}

void sendspeedcontrolvalues(){
serial2.print("speed controller 1 identifier"); //adjust this to follow the pololu ASCII format available here: Pololu - 6.3. ASCII Commands
serial2.println('channel1');
serial2.print("speed controller 2 identifier");
serial2.println('channel2');

}

Now you're getting somewhere ...

CrossRoads:
Now you're getting somewhere ...

any suggestions?

Start writing & compiling.

CrossRoads:
Start writing & compiling.

I have this down but im getting

drew_code.ino:4:2: error: expected initializer before 'void'

drew_code.ino:12:2: error: expected initializer before 'void'

drew_code.ino:42:14: error: expected initializer before '.' token

Error compiling.

Here's my code

int serialbuffer;
int channel1;
int channel2;
int channel3;
int channel4;
int channel5;
int channel6;
int channel7;
int channel8;
int Setup

void setup(){
Setup Serial (9600 baud);
Setup Serial1(115200 baud);
Setup Serial2(115200 baud);
}

void loop(){
Serial1.read(); //calls "readserial1" function
Serial1.println('channel1');
Serial1.print("\t"); //prints a tab to space the values out
Serial1.println('channel2');
Serial1.print("\t");
Serial1.println('channel3');
Serial1.print("\t");
Serial1.println('channel4');
Serial1.print("\t");
Serial1.println('channel5');
Serial1.print("\t");
Serial1.println('channel6');
Serial1.print("\t");
Serial1.println('channel7');
Serial1.print("\t");
Serial1.println('channel8');
Serial1.print("\t");
Serial1.println('last channel');
// sendspeedcontrolvalues(); //calls "sendspeedcontrolvalues" function
}

void Serial1.read(){
while(Serial1.available());

serialbuffer = Serial1.read();
channel1 = Serial1.read();
channel2 = Serial1.read();
channel3 = Serial1.read();
channel4 = Serial1.read();
channel5 = Serial1.read();
channel6 = Serial1.read();
channel7 = Serial1.read();
channel8 = Serial1.read();
serialbuffer = Serial1.read();
}

// void sendspeedcontrolvalues(){
// Serial2.print("speed controller 1 identifier"); //adjust this to follow the pololu ASCII format available here: Pololu - 6.3. ASCII Commands
// Serial2.println('channel1');
// Serial2.print("speed controller 2 identifier");
// Serial2.println('channel2');
// Serial2.print("speed controller 3 identifier");
// Serial2.println('channel3');
// Serial2.print("speed controller 4 identifier");
// Serial2.println('channel4');
// Serial2.print("speed controller 5 identifier");
// Serial2.println('channel5');
// Serial2.print("speed controller 6 identifier");
// Serial2.println('channel6');
// Serial2.print("speed controller 7 identifier");
// Serial2.println('channel7');
// Serial2.print("speed controller 8 identifier");
// Serial2.println('channel8');
// }

int serialbuffer;

Wrong. A buffer is an array or some kind of collection. It is NEVER a single value.

int Setup

WTF?

PaulS:

int serialbuffer;

Wrong. A buffer is an array or some kind of collection. It is NEVER a single value.

int Setup

WTF?

that was the pseudocode like I described, thanks for noticing that though.

this is what it really looks like but im still not getting any values on the serial monitor

int serialbuffer; //Configure a bunch of variables to stick values in from serial.read
int channel1;
int channel2;
int channel3;
int channel4;
int channel5;
int channel6;
int channel7;
int channel8;

//Setup, only runs once
void setup(){
Serial.begin(9600); //Set up serial arduino->computer at 9600 baud (bits per second)
Serial1.begin(115200); //set up serial lemonRX->arduino at 115200 baud (required by LemonRX)
Serial2.begin(115200); //ser up serial arduino->speedcontroller at 115200 baud (unused for now)
}

//loop, runs continuously
void loop(){
readrx(); //calls "readrx" function to read LemonRX serial port
Serial1.print('channel1'); //sends channel1 value to computer
Serial1.print("\t"); //prints a tab to space the values out
Serial1.print('channel2');
Serial1.print("\t");
Serial1.print('channel3');
Serial1.print("\t");
Serial1.print('channel4');
Serial1.print("\t");
Serial1.print('channel5');
Serial1.print("\t");
Serial1.print('channel6');
Serial1.print("\t");
Serial1.print('channel7');
Serial1.print("\t");
Serial1.println('channel8'); //serial.println sends a carriage return after the message. Starts a new line in the serial monitor.
//Until you send a println the message stays on one line. So this will send:
//....
//....
//which will show up as
// ## ## ## ## ## ## ## ##
// ## ## ## ## ## ## ## ##
// ## ## ## ## ## ## ## ##
// in the serial monitor.
}

//"readrx" function, runs when called
void readrx(){ //This opens the "readrx" function called in the Loop
while(Serial1.available()){ //While there is something to read on the serial input
serialbuffer = Serial1.read(); //read the first byte, and throw it away into serialbuffer
channel1 = Serial1.read(); //read the next byte and put it in channel1
channel2 = Serial1.read(); //read the next byte and put it in channel2
channel3 = Serial1.read();
channel4 = Serial1.read();
channel5 = Serial1.read();
channel6 = Serial1.read();
channel7 = Serial1.read();
channel8 = Serial1.read();
serialbuffer = Serial1.read(); //read the last byte and throw it away into serialbuffer
}
}

hello all,

I have a lemon rx and a arduino mega 2560, I was having trouble changing the set of numbers on the serial monitor. Any tips?

Here's my code-

byte serialbuffer; //Configure a bunch of variables to stick values in from serial.read
byte channel1;
byte channel2;
byte channel3;
byte channel4;
byte channel5;
byte channel6;
byte channel7;
byte channel8;

//Setup, only runs once
void setup(){
Serial.begin(9600); //Set up serial arduino->computer at 9600 baud (bits per second)
Serial1.begin(115200); //set up serial lemonRX->arduino at 115200 baud (required by LemonRX)
Serial2.begin(115200); //ser up serial arduino->speedcontroller at 115200 baud (unused for now)
}

//loop, runs continuously
void loop(){
readrx(); //calls "readrx" function to read LemonRX serial port
Serial.print(channel1); //sends channel1 value to computer
Serial.print("\t"); //prints a tab to space the values out
Serial.print(channel2);
Serial.print("\t");
Serial.print(channel3);
Serial.print("\t");
Serial.print(channel4);
Serial.print("\t");
Serial.print(channel5);
Serial.print("\t");
Serial.print(channel6);
Serial.print("\t");
Serial.print(channel7);
Serial.print("\t");
Serial.println(channel8);
//serial.println sends a carriage return after the message. Starts a new line in the serial monitor.
//Until you send a println the message stays on one line. So this will send:
//....
//....
//which will show up as
// ## ## ## ## ## ## ## ##
// ## ## ## ## ## ## ## ##
// ## ## ## ## ## ## ## ##
// in the serial monitor.
}

//"readrx" function, runs when called
void readrx(){ //This opens the "readrx" function called in the Loop
while(Serial1.available()){ //While there is something to read on the serial input
serialbuffer = Serial1.read(); //read the first byte, and throw it away into serialbuffer
channel1 = Serial1.read(); //read the next byte and put it in channel1
channel2 = Serial1.read(); //read the next byte and put it in channel2
channel3 = Serial1.read();
channel4 = Serial1.read();
channel5 = Serial1.read();
channel6 = Serial1.read();
channel7 = Serial1.read();
Serial.print("101");
channel8 = Serial1.read();
serialbuffer = Serial1.read(); //read the last byte and throw it away into serialbuffer
}
}

Any tips?

Any more threads on the same subject are likely to earn you a time-out.

Any tips?

#7 below:

http://forum.arduino.cc/index.php/topic,148850.0.html