Page 1 of 1

Serial port script help

Posted: 13 Sep 2020, 06:14
by Iver
Hi, I have a 4 channel relay with a PIC controller that I want to control from AA script.
Can someone show me how to script this. I'm clueless.
Thanks for any help.

relay #2 on 254 2 1
relay #2 off 254 2 0
baud rate 2400
port 7

Re: Serial port script help

Posted: 13 Sep 2020, 11:32
by fabdev
Hi, here is an example:

Code: Select all

conn = Serial.Connect(7, 2400)
print "Connection = "; conn
Pause(1)
SetRelay(2, 1)
Pause(1)
SetRelay(2, 0)

sub SetRelay(num, state)
  msg = Chr(254) + Chr(num) + Chr(state)
  Serial.Send(msg)
end sub

Re: Serial port script help

Posted: 13 Sep 2020, 16:35
by Iver
Thanks Fabio, I'll try this out.