Copy and paste the code below into a blank Arduino sketch. Then compile and upload it to your Metro.  

// CIRC11 - Relay 

int relayPin = 2;

void setup() {
  pinMode(relayPin, OUTPUT);
}

void loop() {
  digitalWrite(relayPin, HIGH);
  delay(1000);
  digitalWrite(relayPin, LOW);
  delay(1000);
}

Not Working?

Nothing is happening

The example code uses pin 13 and we have the relay connected to pin 2. Make sure you made this change in the code:

  LED_BUILTIN -> 2

No clicking sound

The transistor or coil portion of the circuit isn't quite working. Check the transistor is plugged in the right way.

Not quite working, or not working correctly

The included relays are designed to be soldered rather than used in a breadboard. As such you may need to press it in to ensure it works (and it may pop out occasionally).

This guide was first published on Aug 18, 2017. It was last updated on Jun 12, 2017.

This page (Code) was last updated on Jun 27, 2017.

Text editor powered by tinymce.