Hey Arduino buds, Here is my situation:
I am using a single coil DPDT latching relay to switch between 2 audio signals. I would like to control the relay with a momentary switch that sends a quick pulse to the relay coil. This tutorial:
http://www.electroschematics.com/8975/arduino-control-relay/
has helped me clarify how to operate a single coil relay with an Arduino but with a quick glance at the schematic, it shows that current will only flow in one direction with the rectifier diode shown. (Or so I understand). So with this orientation I cannot reset the relay. Here is the data sheet for the AL-5WN-K relay that I am using:
http://www.fujitsu.com/downloads/MICRO/fcai/relays/a.pdf
Instead of using a rectifier diode across the coils, I propose using two 5.1V Zener diodes with the anodes connected and the cathodes connected to the coil pins on the relay to prevent back flow. Much like this schematic:
http://monomonster.files.wordpress.com/2014/02/schematic.png
The ultimate goal is to program an ATtiny85 to switch the relay, but for now I am using an Arduino Uno. I understand that I need a transistor network to increase the current from the pulse to switch the relay because like the Arduino Uno, the ATtiny85 has a max current output of only 20mA per pin. The relay needs a minimum of around 30mA at 5V to switch. I have been using a 2n3904 transistor and have had luck switching the relay one way, but not no luck switching it back.
Any help or input would be greatly appreciated! Thank you!
Here is the code I am using provided by electroschematics.com:
int pinButton = 8;
int Relay = 2;
int stateRelay = LOW;
int stateButton;
int previous = LOW;
long time = 0;
long debounce = 500;
int stayON = 5000; //stay on for 5000 ms
void setup() {
pinMode(pinButton, INPUT);
pinMode(Relay, OUTPUT);
}
void loop() {
stateButton = digitalRead(pinButton);
if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
if(stateRelay == HIGH){
digitalWrite(Relay, LOW);
} else {
digitalWrite(Relay, HIGH);
delay(stayON);
digitalWrite(Relay, LOW);
}
time = millis();
}
previous == stateButton;
}