Can the Serial.begin(bauderate) be set at run time.
I want to have a selection switch to set the bauderate. So I set bauderate, press reset and bauderate changes.
Can the Serial.begin(bauderate) be set at run time.
I want to have a selection switch to set the bauderate. So I set bauderate, press reset and bauderate changes.
It is set a run time.
When did you think it was set?
Yes, it is set at run time normally in the set-up function of your sketch. However it can be changed at run time anytime you wish via software commands in your sketch. So if you want which baudrate to use to be determined at the start up of your sketch you will have to signal the desired speed you want via switches wired to digital input pin(s) or perhaps by the specific voltage applied to a analog input pin? Set this value into a global variable named speed. Then at the beginning of your startup function, just read what speed is being requested and set the speed variable to the appropriate value and then perform the Serial.begin(speed) command.
Later if you wish, while in the loop section of your could if you wish change the baudrate on-the-run without resetting, just perform the Serial.end() command followed by a new Serial.begin(speed) command where the speed variable has been changed to your desired new speed value.
Hope that helps.
Lefty
Thanks. That's what I wanted to know.
I am use to PIC Basic and in some it can only be set at compile time.
I am use to PIC Basic and in some it can only be set at compile time.
That's pretty dumb, no wonder you've moved to Arduino/C/C++
Rob
Not so. I used the PicSimIde from Oshonsoft and wrote a emulation of the PH Anderson serial LCD. That Basic handles the runtime problems.
The problem with most of the PIC Basics is that if a keyword does not exist, as for the LCD, you have a problem. There are really not any library functions ( except Swordfish )which is the strengths of the GNU compiler used by the Arduino. GNU also has a linking loader. You can write your own library or hopefully someone else has done it. And there are those new keywords that Basic lacks.