I2C is a protocol for attaching devices to a bus. In the case of the standard FSM sketch, I2C is used for interconnection of  2560MEGA boards (as an example). One of the boards is driving the FSM and the other is used for logging purposes (I wanted to use I2C and this is my approach...):

 

When the board is not connected to a computer, it is often very usefull to have something like a LCD display connected or for example a SMS alarm device, to see what's going on with the board.  That is why in the standard sketch, the function "MessageI2C (String Message)" is available. Together with the sketch “SlaveCommunicator” or "SMS Alarm", present in the toolbox, running on a second 2560MEGA board[1], you can fully concentrate on your “master” sketch and send messages via SlaveCommunicator on the LCD display or send SMS message to your cell phone. Calling your Finite State sketch the "master" program, it is possible to send string variables by function MessageI2C to the "slave" sketch[2]. The I2C[3] protocol is a bus for connecting devices. It uses 2 pins on the board; The SDAand SCLpins, together with GND.  

 

About the working of the slave sketch: 

In the setup part of de slave sketch, you have to define the buffer size of the fifo. When receiving a message from the master program, the message is first put into a fifo buffer (this is done via an interrupt service routine). In the main loop of the buffer, the fifo is checked on the number of messages. When there are one or more messages into the fifo, the first message that was added to the buffer is processed and removed from the fifo. When the fifo is full of messages and there has to be added a new message, buffer overflow is signalled. In the standard SlaveCommunicator sketch, this is presented as *BUFFER OVERFLOW* on the LCD display.

 

 

 

[1] Apple: Make a copy of the arduino executable (something like  arduino2) and start the program separately. In this way every instance has an unique serial port. Windows: When working with two (or more) boards, run the arduino program as administrator. Right click on the arduino icon; the “open” menu appears, click on “run as administrator”. This will force different instances of the arduino program, with their own serial port. Otherwise, the same port will be used for the different sketches. 

[2] Of course you can program the slave sketch in another way and give the slave sketch, commands from your master (up to you). Communication is done by the I2C protocol and is used by adding the "wire" library. In this way only the GND, SDA and the SCL pins have to be used on the master sketch, saving all your PWM pins.

[3] I²C (Inter-Integrated Circuit), pronounced I-squared-C, is a multi-master, multi-slave, single-ended, serial computer bus invented by Philips Semiconductor. It is typically used for attaching lower-speed peripheral ICs to processors and microcontrollers. Alternatively I²C is spelled I2C (pronounced I-two-C) or IIC (pronounced I-I-C).