In this part of the lesson, you will add an LED to your Wio Terminal and use it to create a nightlight.
## Hardware
The nightlight now needs an actuator.
The actuator is an **LED**, a [light-emitting diode](https://wikipedia.org/wiki/Light-emitting_diode) that emits light when current flows through it. This is a digital actuator that has 2 states, on and off. Sending a value of 1 turns the LED on, and 0 turns it off. This is an external Grove actuator and needs to be connected to the Wio Terminal.
1. Pick your favorite LED and insert the legs into the two holes on the LED module.
LEDs are light-emitting diodes, and diodes are electronic devices that can only carry current one way. This means the LED needs to be connected the right way round, otherwise it won't work.
One of the legs of the LED is the positive pin, the other is the negative pin. The LED is not perfectly round, and is slightly flatter on one side. The slightly flatter side is the negative pin. When you connect the LED to the module, make sure the pin by the rounded side is connected to the socket marked **+** on the outside of the module, and the flatter side is connected to the socket closer to the middle of the module.
1. The LED module has a spin button that allows you to control the brightness. Turn this all the way up to start with by rotating it anti-clockwise as far as it will go using a small Phillips head screwdriver.
1. Insert one end of a Grove cable into the socket on the LED module. It will only go in one way round.
1. With the Wio Terminal disconnected from your computer or other power supply, connect the other end of the Grove cable to the right-hand side Grove socket on the Wio Terminal as you look at the screen. This is the socket farthest away from the power button.
> 💁 The right-hand Grove socket can be used with analog or digital sensors and actuators. The left-hand socket is for I<sup>2</sup>C and digital sensors and actuators only. I<sup>2</sup>C will be covered in a later lesson.
![The grove LED connected to the right hand socket](../../../images/wio-led.png)
## Program the nightlight
The nightlight can now be programmed using the built in light sensor and the Grove LED.
1. Open the nightlight project in VS Code that you created in the previous part of this assignment
1. Add the following line to the bottom of the `setup` function:
```cpp
pinMode(D0, OUTPUT);
```
This line configures the pin used to communicate with the LED via the Grove port.
The `D0` pin is the digital pin for the right-hand Grove socket. This pin is set to `OUTPUT`, meaning it connects to an actuator and data will be written to the pin.
1. Add the following code immediately before the `delay` in the loop function:
This code checks the `light` value. If this is less than 300 it sends a `HIGH` value to the `D0` digital pin. This `HIGH` is a value of 1, turning on the LED. If the light is greater than or equal to 300, a `LOW` value of 0 is sent to the pin, turning the LED off.
> 💁 When sending digital values to actuators, a LOW value is 0v, and a HIGH value is the max voltage for the device. For the Wio Terminal, the HIGH voltage is 3.3V.
1. Reconnect the Wio Terminal to your computer, and upload the new code as you did before.
1. Cover and uncover the light sensor. Notice how the LED will light up if the light level is 300 or less, and turn off when the light level is greater than 300.