def demo3():
    Laptop Motion Sensor

    Demonstrates how an external program can be invoked and monitored by
    Twisted. Motion is a program that writes samples of the accelerometer
    inside the MacBook to stdout.
    Twisted treats the stdin/out of a process just like any other
    The twisted Process Protocol receives the write events on the outReceived

    The MotionProcessProtocol will log the data samples when they occur.
    motionProcess = motion.MotionProcessProtocol()
    motion.spawnProcess(reactor, motionProcess, 250)
def demo4():
    Integrate the motion sensor and the Arduino device light!

    This demo uses both an arduino.Device object and a motion process.
    The x, y, and z components of the accelerometer data are mapped to the
    r, g, and b components of the LED on the arduino device. The result is
    the ability to change the LED color by moving your laptop around.

    The MotionToLight extends the MotionProcessProtocol. The motionReceived
    event handler calls the set_color method of the arduino device every
    time it gets a new accelerometer sample.

    device = arduino.Device()
    motionProcess = MotionToLight(device)
    motion.spawnProcess(reactor, motionProcess, 250)