From 583b08df28fdf52049ac704d965fbcfd054d1078 Mon Sep 17 00:00:00 2001 From: Ron Hale-Evans Date: Mon, 11 Jul 2016 12:54:28 -0700 Subject: [PATCH] Wrote new Serial topic --- docs/reference/serial/redirect-to.md | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docs/reference/serial/redirect-to.md diff --git a/docs/reference/serial/redirect-to.md b/docs/reference/serial/redirect-to.md new file mode 100644 index 00000000..0cfb6671 --- /dev/null +++ b/docs/reference/serial/redirect-to.md @@ -0,0 +1,31 @@ +# Serial Redirect To + +Dynamically configure the serial instance to use pins other than +``USBTX`` and ``USBRX``. + +```sig +serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200); +``` + +### Parameters + +* ``tx``: the [serial pin](/device/pins) on which to transmit data +* ``rx``: the [serial pin](/device/pins) on which to receive data +* ``rate``: the baud rate at which to transmit and receive data (either `9600` or ``115200``) + +### Example + +When button ``A`` is pressed, the following example reconfigures the +serial instance. The new configuration uses pin ``P1`` to transmit and +``P2`` to receive, at a baud rate of `9600`. + +```blocks +input.onButtonPressed(Button.A, () => { + serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600); +}); +``` + +### See also + +[serial](/device/serial) +