A simple way to detect motion is using a PIR sensor. This sensor measures infrared light radiation emitted by the objects in its range. By detecting changes in the amount of radiation, it can detect motion.
Using the relay circuit from the previous step and having the AC plug disconnected from the socket, add the following connections:
Your PIR sensor should have three pins. Be sure to connect its VCC pin to the Galileo's 5 V pin, the GND pin to the Galileo's ground, and the OUT pin to the Galileo's pin 2. Whenever the sensor detects motion, we'll be able to read the value HIGH on the Galileo's pin 2. When the sensor stops detecting, we'll be able to read LOW.
Open the Arduino IDE, power on your Galileo (just the Galileo, not the lightbulb plug), and upload the following code:
// Pin where we will read the...