It’s easy to connect to devices through the serial port with Experimentor Software using the “SerialPort” driver, that allows read/write access to the serial port.

Setting up the serial port

It’s possible to configure many aspects of the serial port.

define port = “COM3″ Define which COM port you are trying to connect to, as a string; the default is “COM3″.
define baud = 9600 Define the baud rate to use as a number; the default is 9600.
define parity = “None” Define the baud rate to use as a number; the default is “None”.
The valid options are “None”, “Even”, “Odd”, “Space”, and “Mark”.
define stopbits = 1 Define the stop bits to use as a number; the default is 1.
The valid options are 1, 1.5, or 2.

Any changes to these values after the serial port device has been created are ignored.

Using the serial port

Using the serial port is pretty easy. There are two variables attached to the serial port:

Value This variable contains the last input value read from the serial port.
Writing values to this variable will NOT send values to the serial port.
OutputValue This variable is used to actually write values out to the serial port.
Reading from this variable will simply let you see the last value written
to the serial port.

Example

Here’s a set of codes that use the serial port. The first block sets up the serial port on COM 3. The second block of code says that whenever the serial port’s incoming value changes to print out the value to the Experimentor. The final block (with the while loop) writes out a 1 or 0 every 100 milliseconds. In my case the device I’m plugging into the serial port turns on a light with a 1 and turns it off with a zero.