help please!!! noob here!....Serial comunication

help please.
i am using arduino uno and arduino mega and an mpu 6050. mpu 6050 is connected to the arduino uno which will process the sensor readings via fuzzy logic. the output will then be send to serial1 of the arduino mega. which will then send it to serial(0) which is connected to pc which would allow me to see if the output is correct. i am planning to use the output to control a servo.
problem is i was expecting to receive an output of 77 but the arduino mega is showing me 55… i really don’t know what happen… i tried connecting the arduino uno to the pc to see what is the output it was giving on the serial(0) and i can see that it was 77… can someone please tell me what did i do wrong and tell me if it is okay to directly use if angle = serial1.read(); in servo.write(angle); as a command to control a servo?thank you so much…
below is the arduino sketch that i made.

fis_header.h (638 Bytes)

sketch_jan11a.ino (46.5 KB)

sketch_jan15a.ino (342 Bytes)

below is the arduino sketch that i made.

It would REALLY help to use MEANINGFUL names for the sketches.

Why are all those #define statements in the sketch? They belong in a header file.

Why do you have a boatload of functions that do nothing but return global variables?

void setup()
{

That's an unreasonable amount of white space.

The commented out code is NOT the problem. GET RID OF IT!

#define FIS_TYPE float

STUPID! Defining another name for float is NOT value added. In fact, it makes it more difficult to understand the code.

    Serial.println(g_fisOutput[0], 2);

Anonymous printing sucks. How the heck are you supposed to know what this number means when it appears in the serial monitor app?

It is nonsense to talk about getting 55, instead of 77, when you are sending floats to two decimal places.

You sent a string. You read the characters, one at a time, and assumed that you read a float. Nonsense. Pay some attention to what Serial.read() actually does.

Run_piggy: problem is i was expecting to receive an output of 77 but the arduino mega is showing me 55.... i really don't know what happen..

You can't seriously expect someone to wade through 46k of code to answer a question like that.

Can you reproduce the problem in a very short program?

...R

You can't seriously expect someone to wade through 46k of code to answer a question like that.

Why not? I did.

PaulS:
Why not? I did.

I prostrate myself before your geniousness and generosity.

…R

PaulS: ```

define FIS_TYPE float



STUPID! Defining another name for float is NOT value added. In fact, it makes it more difficult to understand the code.

Sorry i just got that from this site: http://www.makeproto.com/projects/fuzzy/matlab_arduino_FIST/index.php

it lets you convert matlab fuzzy inference system to arduino c code.

PaulS: Why not? I did.

i thank thee for such munificence....

Robin2: You can't seriously expect someone to wade through 46k of code to answer a question like that.

Can you reproduce the problem in a very short program?

...R

Shortened version of Sender...

float FuzzyOutput;
void setup()
{      
  Serial.begin(19200);\
}
void loop()
{
    Serial.println(FuzzyOutput, 2);   
}

Reciever:

float Angle;
void setup() {
// Serial port enable
Serial1.begin(19200);
Serial.begin(19200);
}
void loop() {
// if there is bytes available coming from the serial port
if (Serial1.available()) {
// set the values to the ‘incomingByte’ variable
Angle = Serial1.read();
// write the value to the pin 11
Serial.println(Angle,2);
}
}

You are still sending something like “23.66” and reading ONE character, like ‘2’, and expecting that to equal 23.66.

Some mandatory reading, in my opinion: http://forum.arduino.cc/index.php?topic=396450.0

thanks i think i could make some progress with this.