How can I control the Arduino via computer?

I spent about 15 minutes writing this post. It got deleted, no explanation. So again:
Could anyone please explain how to connect a computer to the Arduino so when I press a key on the keyboard (or run an Applescript) , the Arduino does something. As far as I understand the communication between computer and Arduino is only to upload programs, not to have tArduino wait for computer input. I thought about cutting a USB cable in half and connecting the data wires to the Arduino but then I would still need a program on my Mac to tell the USB port to send a signal. Perhaps I could use the sound out port and when the Arduino hears sound it runs an action? Hopefully there is an easier way. Thank you.

As far as I understand the communication between computer and Arduino is only to upload programs

This is a misunderstanding.

An Arduino can receive serial data from a PC/MAC and you could write a program to act on the data it receives.

Another option might be to use Firmata to control pins on a Arduino. There are examples and test programs for all the main operating systems (see here)

This Python - Arduino demo may help with understanding.

I think someone successfully modified it to work on an Apple PC - but I can't afford them myself. It's probably only necessary to put in the correct serial port reference in the Python code.


I went to all links on this page you suggested but I still don't understand what I need to do to interact with the Arduino from my Mac. Could someone be kind enough to let me know where I can get more information or which program I need to download? Thank you

In the Post (Reply #4) in the link I gave you there are 3 programs.

ArduinoPC2.ino is the Arduino code is the Python program

The third file is a JRuby program (similar to the Python program) which probably has no interest for you.


The most simple way to do it is with the Arduino IDE’s Serial Monitor:

Upload this code to your Arduino:

const byte LEDpin = LED_BUILTIN;
const int intervalDuration = 1000;

void setup() {
  pinMode(LEDpin, OUTPUT);

void loop() {
  if (Serial.available() > 0) {
    if ( == 'b') {
      digitalWrite(LEDpin, HIGH);
      digitalWrite(LEDpin, LOW);

Tools > Serial Monitor

Select 9600 from the baud menu at the lower right side of the Serial Monitor window.

Click on the input bar at the top of the Serial Monitor window

Type the letter b

Press Enter

The LED on the Arduino will turn on(or off depending on how it’s wired) for one second every time you send a b via the Serial Monitor(or any other terminal program if configured correctly).

This system is far from ideal but it can be expanded to implement a simple user interface that doesn’t require any additional application to be installed.

For my own home automation I prefer to communicate with my Arduinos via Ethernet, rather than Serial which is not appropriate for my needs. I’m using an application called EventGhost on my computers which allows me to send commands to the Arduinos triggered by keyboard input as well as various GUIs. EventGhost is a Windows program so that probably won’t be useful to you but I’d guess there’s some sort of an Apple analog that may be easier to implement than starting from scratch.