Jump to content

Reading from Serial Port


1 post in this topic

Recommended Posts

Hello,

 

I am using the SerialPortX add-on for applescripts. Basically what I want is for the script to control volume on my mac based on output from an Arduino (thus the need for SerialPortX). 

 

The output from Arduino is sent as characters. As of right now, the letter "A" is sent form the Arduino to the computer to increase the volume and the number "0" to decrease Volume. The characters themselves can be changed, but I will need to add a few more characters to increase functionality (play/pause, next song, previous song, etc). 

 

I need help/the code on how to read the output from the Serial port. Thanks in advance

 

 

 

set use_port to "/dev/cu.usbserial-AE01EC89"

 

on idle

if (get serialport list) contains use_port then

set myPort to serialport open use_port bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0

if myPort ≠ -1 then -- check the port opened correctly

 

 

 

 

 

serialport close myPort

end if

end if

return

end idle

Link to comment
Share on other sites

 Share

×
×
  • Create New...