Go Down

Topic: Serial baud rate adjustment without reset? (Read 858 times) previous topic - next topic

renasis

Hello,

Is it possible to adjust the baudrate of the serial port without a reset?

Thanks,

-ren

robtillaart


Yes, something like this
Code: [Select]

void setup()
{
  Serial.begin(9600);
  Serial.print("press A for high speed mode, any other key to keep 9600");

  while(Serial.available == 0);
  if (Serial.Read() == 'A') Serial.begin(115200);
}

void loop()
{
  Serial.println("Hello world");
  delay(1000);
}

 
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

floresta

Quote
Yes, something like this...

How does this get around the auto reset feature?

Don

Runaway Pancake

Everything passes through setup (), but you can place a call to Serial.begin() anywhere.  I think it's commonplace having Serial.begin( ); in the setup(), but it could be put in a baudrate function all its own. 
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"
Hey - it's "bipolar transistor" or "junction transistor"; "BJT" is just stupid.

robtillaart


biggest problem is that you have to synchronize the sender / receiver when switching. But you can make a sort of "encrypted" communication by switching the baudrate per byte.

NOte that the hardware can do almost any baudrate where software serial has the standard values .

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

renasis

robtillaart,

Thanks, I suspected that could call begin twice, but I wasn't sure...thanks for clearing it up.

-ren

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy