> For the complete documentation index, see [llms.txt](https://longer-vision-robot.gitbook.io/arduino-full-stack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://longer-vision-robot.gitbook.io/arduino-full-stack/09_switches/016_relay.md).

# 9.4 Relay

## Hardware Wiring

![Relay](https://2341898987-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LCFDbcteyTR3tQSs-5x%2F-LCFE4dCRQBMq1ajywfh%2F-LCFECIz6rqOQe-9x5qS%2F016_relay.jpg?generation=1526059558480061\&alt=media)

## Sketch

The code can be found at [Examples\_Arduino - sensor-kit-for-arduino - \_016\_Relay - \_016\_Relay.ino](https://github.com/LongerVisionRobot/Examples_Arduino/blob/master/sensor-kit-for-arduino/_016_Relay/_016_Relay.ino).

```
int relay = 10; // Define relay pin
void setup()
{
  pinMode(relay,OUTPUT); // Define relay pin as output
}
void loop()
{
  digitalWrite(relay,HIGH); // Relay open
  delay(1000);
  digitalWrite(relay,LOW);  // Relay close
  delay(1000);
}
```
