Skip to content

Instantly share code, notes, and snippets.

Last active August 3, 2016 15:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
-- Authware 7.0 Script,
-- Robin van Emden 2015
-- Communicates with an Arduino
-- Over Serial Port on a PC
-- Implements DirectCommunication Xtra from
-- Instantiate the DirectCommunication Xtra
Trace("--- DirectCommunication -- ")
Device := NewObject("DirectCommunication" ; 0)
-- Show available USB and Serial ports
Trace("--- getDevices -- ")
Devices := CallObject (Device ; "commGetDevices")
Trace (Devices)
-- Connect to Arduino Serial Port
Trace("--- commConnect -- ")
Error := CallObject (Device ; "commConnect"; "\\\\.\\COM17")
if (Error) then
Trace ("Can't connect to the device, error # "^Error)
Trace ("A connection was established successfully.")
end if
-- Set the Baud Rate
Trace("--- commSetBaudRate -- ")
Error := CallObject (Device; "commSetBaudRate"; 9600 )
if (Error) then
Trace ("Can't set the baud rate, error # "^Error)
Trace ("The baud rate was set successfully.")
end if
-- Send pulse values to arduino
-- Here: Port A, Cool, Power 100%, for 1000ms
NumOfCharsSent := CallObject (Device, "commWrite", "<0,0,100,1000>"^Return)
Trace (NumOfCharsSent^" characters were successfully sent to the device.")
-- trace response
repeat with i := 1 to 10
Trace (CallObject (Device, "commRead"))
end repeat
-- disconnect port and delete the object
Trace (CallObject (Device; "commDisconnect"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment