Serial port script help

Scripts and programs to automate Astroart
Post Reply
Iver
Posts: 103
Joined: 08 Jan 2019, 04:32
Location: Monterey county, Ca.

Serial port script help

Post by Iver » 13 Sep 2020, 06:14

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
Iver

fabdev
Posts: 461
Joined: 03 Dec 2018, 21:43

Re: Serial port script help

Post by fabdev » 13 Sep 2020, 11:32

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

Iver
Posts: 103
Joined: 08 Jan 2019, 04:32
Location: Monterey county, Ca.

Re: Serial port script help

Post by Iver » 13 Sep 2020, 16:35

Thanks Fabio, I'll try this out.
Iver

Post Reply