This is old and very odd example code for kids and adults. The code example of DD83 is really a mess and doesn't deserve to mention as example on this site.

Demonstration project: Arduino as slave to a PC "master" device.

An Arduino was given an LED and a switch. With the software provided for it in the demo, a PC's screen has a window with buttons for "Turn LED on" and "Turn LED off", and a text message saying "Switch input is high" or "Switch input is low". The code for the program to run in the Arduino is also supplied, of course.

The hardware and software in the Arduino is "generic", and could be used unchanged with many different "master" controllers.... part of the reason for the project was to encourage others to show other solutions.

The demonstration's master device was programmed with Delphi, but the discussion of the demo should enable proponents of other languages to create equivalent applications to show people how easy it is to use the language they like. Such people are invited to ask for links to their work from the demo's page.

The project was never meant to be particularly useful in it's own right. Rather, it serves as a template. For instance, the switch could be replaced with a temperature sensor and the LED with a relay to turn a home's heating on. The PC + Arduino could then become the world's most over-engineered thermostat! (Of course that could be done with Arduino alone!) But other systems consisting of (one or more) Arduinos connected to a PC are more meaningful.

The way the software is written, it would not be hard to turn things around, and have the Arduino as the master, the PC as the slave.

The system uses a dedicated serial link, leaving the Arduino's "main" serial link dedicated to programming the Arduino and communicating with the Arduino Development Environment's serial monitor. But again, it would be trivial to "move" the serial link to pins D0 and D1, if you wished to.