Baud rate

I assumed that if the baud rate in the Arduino IDE was the same as the baud rate in written in my code under the Serial.begin() function that there would be no significant problem but a little experimentation has yielded wildly different results. Any comments?

It is the baud rate in the Serial Monitor program that matters, not the Arduino IDE.

What problem do you actually have ?

jkiddmd:
I assumed that if the baud rate in the Arduino IDE was the same as the baud rate in written in my code under the Serial.begin() function that there would be no significant problem but a little experimentation has yielded wildly different results. Any comments?

The baud rate in the IDE is what you select in the serial monitor. The baud rate in the program is what you have in Serial.begin(). They aren't necessarily the same, but should be for meaningful results.

Michinyon you asked what I was doing. I wrote a little program to help explain to myself how pointers work. I noticed that upon opening the serial monitor that there was always a bit of junk at the beginning. I fiddled around with a few different things to try to get rid of it. Then I started fiddling with the baud rate. At 9600 things worked fine but at other rates the output was a mess! This, even though I had set the rate in the IDE monitor to equal what I set in Serial.begin(). I just could not figure it out despite hours of fiddling and reading.

// A derivation of a code I learned from Jack Purdum.  One of the best instructors of Arduino C I have encountered.
#include <stdio.h>
#define pause 5000
#define readingPause 8000
int number = 5; // Define and declare an int variable
int *ptrNumber = NULL; // Define and declare an int pointer
void setup () {
  Serial.begin(9600);
}

void loop(){
  Serial.println ("We have defined an int variable called number.  It has an lvalue address  and an rvalue which is what is held at that address.");
  delay(readingPause);
  Serial.println ("We have also defined a int pointer called ptrNumber which has a 2byte address and an rvalue which is meant to hold a variables lvalue address.");
  delay (readingPause);
  Serial.println ("We have set the rvalue to null in order to avoid junk data.");
  delay(pause);
  Serial.println ("Here are the results.");
  delay(pause);
  
 Serial.print("The lvalue for ptrNumber is ");
  Serial.println((long)&ptrNumber,DEC);// The long is there to tell the compiler the data type we wish to use for the ptrNumber address, DEC instructs the reporting in base 10.
  delay(pause);
  Serial.print("The lvalue for number is ");  
  Serial.println ((long)&number,DEC);
  delay(pause);
  Serial.print("The rvalue for our pointer is ");
  Serial.println((long)ptrNumber,DEC);
  delay(pause);
  Serial.print("The rvalue for number is ");
  Serial.println (number);
  delay(8000);
  
  ptrNumber = &number;// Point the pointer at the lvalue of 'number'.  This should make the pointer r value 'number's lvalue
  /*
       Now whend we querry the processor as to the lvalue of number and the rvalue of ptrNumber we should get the same thing.
   */
  Serial.println ("Now we point the pointer at number using the address operator &.");
  delay(readingPause);
  Serial.println ("The code looks like ptrNumber = &number ");
  delay(pause);
  Serial.println ("Here are the results:");
  delay (pause);
  Serial.print("The lvalue for ptrNumber is ");
  Serial.println((long)&ptrNumber,DEC);
  delay(pause);
  Serial.print("The lvalue for number is ");  
  Serial.println ((long)&number,DEC);
  delay(pause);
  Serial.print("The rvalue for our pointer is now ");
  Serial.println((long)ptrNumber,DEC);
  delay(pause);
  Serial.print("The rvalue for number is still  ");
  Serial.println (number);
  delay(pause);
  Serial.println("As you can see the rvalue for the pointer is the same as the lvalue of the pointers target.  This is the result of pointing the pointer.");
  delay(readingPause);
  
  /* Now we will use the indirection operator to allow the pointer to take control of the r value held at numbers address*/
  Serial.println ("Now we use the indirection operator to allow our pointer to take control of the r value held at numbers address.");
  delay(readingPause);
  Serial.println ("We will instruct the pointer to change the rvalue of number from 5 to 10 using the indirection operator");
  delay(readingPause);
  Serial.println ("The code looks like: *ptrNumber = 10 ");
  delay(pause);
  Serial.println ("Here are the results: ");
  *ptrNumber = 10;
  delay(pause);
  Serial.print("The lvalue for ptrNumber is ");
  Serial.println((long)&ptrNumber,DEC);
  delay(pause);
  Serial.print("The lvalue for number is ");  
  Serial.println ((long)&number,DEC);
  delay(pause);
  Serial.print("The rvalue for our pointer is still ");
  Serial.println((long)ptrNumber,DEC);
  delay(pause);
  Serial.print("The rvalue for number is now ");
  Serial.println (number);
  delay(pause);
  Serial.println ("In this example we defined and declared a int variable.  We then defined a pointer and set its rvalue to null.");
  delay(readingPause); 
  Serial.println ("Next we pointed the pointer using the address operator &.  This placed the target variables lvalue in the pointers rvalue.");
  delay(readingPause);
  Serial.println ("This ultimately gives the pointer control over the r value held at the variables address.");
  delay(readingPause);
  Serial.println ("Finally we gave the pointer the power to change the r value of the variable by using the indirection operator *.");
  delay(readingPause);
  Serial.println ("Most importantly, one must remember that all this is possible because the pointer had the variables address, which is held in the pointers rvalue.");
  

}

You are very soon going to run out of RAM doing it like that. I suggest you use the F macro, eg.

  Serial.print(F("The rvalue for number is now "));

Ditto for every other line which prints lots of constant string data.

I noticed that upon opening the serial monitor that there was always a bit of junk at the beginning.

That's a bit of a side-effect of the hardware adjusting to a new baud rate. I usually throw in a blank line at the start of my sketch and ignore the junk.

Thanks,
good idea.