Go Down

Topic: Serial/MIDI declaration question (Read 733 times) previous topic - next topic

Tommy T

Hi guys,
I am working on project which in its default form communicates with a PC over the serial link to transfer speed data.

I am currently trying to add a function where it can switch and instead output the data in MIDI format through a different connector depending on a button state (but still using pins 0 and 1 to save input/outputs).

In my current program I set the serial (Serial.begin (9600)) in the void setup, my question is can I later declare the serial port to work as midi (Serial.begin(31250)) or can the serial port only be initialised once at one speed?

Many thanks in advance

Tommy T

48 views and no ideas? Come on people don't let me down  :)


It may sound stupid, but did you try? You wouldn't break anything trying to Serial.begin() twice.

Tommy T

Hey thanks for the reply, yeah I have tried it and it will compile however I don't currently have access to the midi receiving hardware so cannot tell if it is working correctly, was hoping someone may know.

I guess I will have to wait for then, thanks anyway though


Tommy, there is no problem with calling Serial.begin multiple times at multiple speeds.  To test, I made a little sketch that prints data at two different speeds:

Code: [Select]
void setup()
 Serial.println("Hello at 9600");
 Serial.println("Hello at 115200");
void loop(){}

When I set my serial monitor to 9600 I got reasonable text then garbage.  At 115K it was the other way around.

I think your only concern is whether 31250 works as a baud rate.

Good luck!


Go Up