'code for the sending (input) box 'It reads data from a pin and then send it through the serial line 'in pin 20 (you can change this pin number to the one you want. Option Explicit Private Const InputBufferSize As Integer = 64 ' Input buffer Private Const OutputBufferSize As Integer = 64 ' Output buffer Private InputBuffer(1 To InputBufferSize) As Byte Private OutputBuffer(1 To OutputBufferSize) As Byte Const outPin as Byte = 12 Public Sub OpenSerialPort(ByVal PortNumber As Byte, ByVal BaudRate As Long) Dim outputpinNumber as Byte outputpinNumber = outPin call DefineCom3(0, outputpinNumber, bx0000_1000) 'Use pin 12 as output for serial data (you can choose the one you want) Call OpenQueue(InputBuffer, InputBufferSize) Call OpenQueue(OutputBuffer, OutputBufferSize) Call OpenCom(PortNumber, BaudRate, InputBuffer, OutputBuffer) End Sub 'Send a byte through the serial port Public Sub PutByte(ByVal Value As Byte) Call PutQueue(OutputBuffer, Value, 1) End Sub Public Sub Main() Dim outbyte as Byte Dim inbyte as Byte Call OpenSerialPort( 3, 19200 ) 'Open the serial port Dim value as single Dim sensorPin as Byte Dim NEEDLEPin as byte Dim HANDSPin as byte Dim LEGSPin as byte Dim INTIMATEPin as byte Dim STOMACHPin as byte Dim HEARTPin as byte Dim MOUTHPin as byte Dim EYESPin as byte Dim NEEDLEVOLT as single Dim HANDSVOLT as single Dim LEGSVOLT as single Dim INTIMATEVOLT as single Dim STOMACHVOLT as single Dim HEARTVOLT as single Dim MOUTHVOLT as single Dim EYESVOLT as single NEEDLEPin = 20 HANDSPin = 19 LEGSPin = 18 INTIMATEPin = 17 STOMACHPin = 16 HEARTPin = 15 MOUTHPin = 14 EYESPin = 13 outbyte = 0 Do outbyte = 0 call GetADC(EYESPin, EYESVOLT) if (EYESVOLT > 0.0) then outbyte = 1 call PutByte(outbyte) 'Send the byte end if call GetADC(MOUTHPin, MOUTHVOLT) if (MOUTHVOLT > 0.0) then outbyte = 35 call PutByte(outbyte) 'Send the byte end if call GetADC(HEARTPin, HEARTVOLT) if (HEARTVOLT > 0.0) then outbyte = 70 call PutByte(outbyte) 'Send the byte end if call GetADC(STOMACHPin, STOMACHVOLT) if (STOMACHVOLT > 0.0) then outbyte = 105 call PutByte(outbyte) 'Send the byte end if call GetADC(INTIMATEPin, INTIMATEVOLT) if (INTIMATEVOLT > 0.0) then outbyte = 140 call PutByte(outbyte) 'Send the byte end if call GetADC(LEGSPin, LEGSVOLT) if (LEGSVOLT > 0.0) then outbyte = 175 call PutByte(outbyte) 'Send the byte end if call GetADC(HANDSPin, HANDSVOLT) if (HANDSVOLT > 0.0) then outbyte = 210 call PutByte(outbyte) 'Send the byte end if call GetADC(NEEDLEPin, NEEDLEVOLT) if (NEEDLEVOLT > 0.0) then outbyte = 245 call PutByte(outbyte) 'Send the byte end if if (outByte = 0) then 'no needle event detected outbyte = 0 call putByte(outByte) end if Loop End Sub