Hi all.
When I initialise the Serial device (i.e. USB serial), it seems to unexpectedly initialise the pins for UART1 as well.
I have an application where I am using digital pins 0 and 1 as ordinary switch inputs. Closing the switch pulls the pin to ground. I naturally need pullups. Using this code:
The pullups do not appear to be correctly set (pin 1 always reads low - even when the switch is not closed).
When I reorder things this way:
Everything works as expected. Digital pins 0 and 1 are UART1 and it seems to me that somehow initialising Serial (i.e. USB serial) is also initialising pins 0 and 1 as if UART1 was also to be active.
I have tested by removing the Serial initialisation line and pins 0 and 1 are correctly set as pullups.
I am using Teensyduino Beta#3.
Apologies if this is expected behaviour but please let me know if it is.
Have fun
BBUK
When I initialise the Serial device (i.e. USB serial), it seems to unexpectedly initialise the pins for UART1 as well.
I have an application where I am using digital pins 0 and 1 as ordinary switch inputs. Closing the switch pulls the pin to ground. I naturally need pullups. Using this code:
Code:
[...]
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
long unsigned startTime = millis ();
while (!Serial && ((millis () - startTime) <= 5000));
[...]
The pullups do not appear to be correctly set (pin 1 always reads low - even when the switch is not closed).
When I reorder things this way:
Code:
[...]
long unsigned startTime = millis ();
while (!Serial && ((millis () - startTime) <= 5000));
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
[...]
Everything works as expected. Digital pins 0 and 1 are UART1 and it seems to me that somehow initialising Serial (i.e. USB serial) is also initialising pins 0 and 1 as if UART1 was also to be active.
I have tested by removing the Serial initialisation line and pins 0 and 1 are correctly set as pullups.
I am using Teensyduino Beta#3.
Apologies if this is expected behaviour but please let me know if it is.
Have fun
BBUK