So I have a small project that I am working on and I need some basic commands to arduino. Each command is one character long. For the test I have application that turns on a LED if a "l" character is recieved. So I tryed that with the serial monitor - it wroks.
But now I want to turn that LED on with appleScript. I found a serialPort X (applescript extension that should enable serial communication). So I can open the port to the arduino. But I can't figure out how to turn the LED on with it. If I do this
serialport write "l" to portRef
that should send an l character to the arduino and turn on the LED - but it doesn't. I see the serial RX/TX LEDs blink on the arduino and the LED blinks too - but it doesn't stay on (it should stay on). So why isn't this working?
EDIT: The above script works if arduino IDE is in "Serial Monitor" mode. But if the arduino software isn't working the thing wont work.
EDIT2: I also tryed this code:
And the results are the same. The thing works if the arduino IDE is in "Serial Monitoring" but if it isn't I just get a LED that blinks when I press enter.
What happens if you try to send from apple script serveral times fast one after the other ? Do you see one blink or serveral ?
Maybee something happens that resets the Arduino board right after it turns the LED on.
Just one blink! I thought about the board resetting after it gets the message too. Because if I unplug the board and then plug it in I get the same result. RX blinks, TX blinks and LED blinks. One after the other.
I know nothing about Mac's and applescript, but it might have something to do with how apple script handles the DTR signal in the serial port connection.
Try to read this thread:
Well since I tryed it with normal C that works on linux/windows/mac and I got the same results the problem probably isn't with applescript. But somewhere else.
I also tryed the same code with another arduino (Duemilanove too but with Atmega 328). And the results are almost identical. About disabling the auto reset - i don't know if this is the problem.
EDIT: Disabled the autoreset by wiring 100ohm resistor between +5V and reset. And now the whole thing is working. But as I read this should only be used as a temp solution. I need something thal last a little longer.