SEROUT pin,baudmode,({#}data,{#}data...)

Pin - is a variable/constant which specifies the i/o pin to use.

Baudmode - is a variable/constant (0-7) which specifies the mode:

Txxx give a true output (idle high).

Nxxx give an inverted output (idle low.

For 08 / 08M / 18 / 18A / 28 / 28A parts

4MHz 8MHz 16MHz
T300_4 T600_8 T1200_16
T600_4 T1200_8 T2400_16
T1200_4 T2400_8 T4800_16
T2400_4 T4800_8 T9600_16
N300_4 N600_8 N1200_16
N600_4 N1200_8 N2400_16
N1200_4 N2400_8 N4800_16
N2400_4 N4800_8 N9600_16

For all other parts (e.g. all X1, X2, M2 parts)

4MHz 8MHz 16MHz 32MHz 64MHz
T600_4 T1200_4 T2400_16 T4800_32 T9600_64
T1200_4 T2400_8 T4800_16 T9600_32 T19200_64
T2400_4 T4800_8 T9600_16 T19200_32 T38400_64
T4800_4 T9600_8 T19200_16 T38400_32 T76800_64
N600_4 N1200_8 N2400_16 N4800_32 N9600_64
N1200_4 N2400_8 N4800_16 N9600_32 N19200_64
N2400_4 N4800_8 N9600_16 N19200_32 N38400_64
N4800_4 N9600_8 N19200_16 N38400_32 N76800_64

Data - are variables/constants (0-255) which provide the data to be output. Optional #'s are for outputting ASCII decimal numbers, rather than raw characters. Text can be enclosed in speech marks ("Hello")


Transmit serial data output (8 data bits, no parity, 1 stop bit).

The serout command is used to transmit serial data from an output pin of the microcontroller.

To send data via the serial out download output pin the sertxd command is recommended. On some PICAXE the serout command cannot be used to send data via the serial out download output pin and the sertxd command must be used.

Pin specifies the output pin to be used. Baud mode specifies the baud rate and polarity of the signal. When receiving RS232 level data using a simple resistor interface, use N (inverted) signals. When using a MAX232 type interface use T (true) signals. The protocol is fixed at N,8,1 (no parity, 8 data bits, 1 stop bit).

A 'N' baud rate idles low, with data pulse going high.

A 'T' baud rate idles high, with data pulses going low.

When using a T baud rate the very first byte may become corrupt if the output pin was low before the serout command (the pin will be automatically left high after the serout command). To avoid this issue place the line high (via a high command') a few milliseconds before the very first serout command.

The # symbol allows ASCII output. Therefore #b1, when b1 contains the data 126, will output the ascii characters "1" "2" "6" rather than the raw data 126. The # symbol can also be used with word, bit and input pin variables.

Please also see the affect of resonator clock speed, and explanation notes of the 'serin' command, as all of these notes also apply to the serout command.

Applies To:
See Also:
Related Create:

Transmit serial data

Transfer the values stored in EEPROM location 0 to 63 to a serial LCD at 2400 baud

Code Example:
main:	for b0 = 0 to 63	; start a loop
	  read b0,b1		; read value into b1
	  serout 7,N2400,(b1)	; transmit value to serial LCD
	next b0			; next loop
Copy Code Submit an Example

Submit Your Own Code!

You must be logged in to submit code examples. Login now.