Sparkfun Relay problem - something wrong?

Am trying to setup the Sparkfun relay board using an arduino as the controller. Received the parts Friday and assembled that night, but am not having any luck with it… :frowning: Most of the parts were ordered from Sparkfun, except for the transistor, resistors, and led. The resistors and led are fairly common so don’t (at least hope not) think messed those up. Used the schematic posted and the picture as a rough guide (the picture is missing one of the 10K resistors, on purpose?).

This is my first real attempt at making a board such as this (can program them no problem but hardware is a challenge). For testing purposes I do not have main power hooked to relay, am looking at LED on the board to determine if it is working and used a multi-meter to check continuity between the main contacts (no luck so far).

Am using this transistor (http://www.futurlec.com/Transistors/C9012.shtml) as had it handy, but the schematic calls for this one (http://www.sparkfun.com/datasheets/Comp … 2N3904.pdf). Could that potentially be the problem? I really unsure what the specs mean… :oops:

This is the code am running to try and test this… When pressing the spacebar, the window says relay on, but the led does not light on the board.

// Maurice Ribble
// 4-6-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code just lets you turn a digital out pin on and off.  That's
// all that is needed to verify a relay curcuit is working.
// Press the space bar to toggle the relay on and off.

#define RELAY_PIN 3

void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  Serial.begin(9600); // open serial
  Serial.println("Press the spacebar to toggle relay on/off");
}

void loop()
{
  static int relayVal = 0;
  int cmd;

  while (Serial.available() > 0)
  {
    cmd = Serial.read();

    switch (cmd)
    {
    case ' ':
      {
        relayVal ^= 1; // xor current value with 1 (causes value to toggle)
        if (relayVal)
          Serial.println("Relay on");
        else
          Serial.println("Relay off");
        break;
      }
    default:
      {
        Serial.println("Press the spacebar to toggle relay on/off");
      }
    }

    if (relayVal)
      digitalWrite(RELAY_PIN, HIGH);
    else
      digitalWrite(RELAY_PIN, LOW);
   }
}

The transistor that you have on hand is PNP and the circuit requires a NPN. They are completely opposite and need to be driven differently.

Thank you riden… I have a NPN version also (http://www.futurlec.com/Transistors/C9013.shtml) that will try and replace… Hope it works well, lol. Teaches me for trying to save a couple cents.

I looked at the schematic of the relay board and just about any general purpose NPN will work for you.

Thank you riden. I was able to get the relay working (hear it now) by replacing that transistor. The LED doesn’t function but am more than ok with that as can now continue on my project… :slight_smile:

Great! Perhaps the LED is inserted backwards. Have fun with your project.