Hi all,
I am trying to turn an LED on and off with my relay and I can't get it to work (my LED constantly remains on and never switches off). I'm following the instructables lesson found here (https://www.instructables.com/id/How-to-use-any-relay-with-your-arduino-the-safe-wa/) except that I don't have the same parts as the original writer. I am using:
2 x 220 ohm resistors
1 x MC7815C transistor
1 x HP 6N136 optocoupler
1 x JS1-5V-F relay
1 x 1N4005 diode
1 x NS-AC1200 insignia ac adapter (for the 12V supply)
I am connecting my optocoupler to pin 5 and using this program:
int in1 = 5;
void setup() {
// put your setup code here, to run once:
pinMode (in1, OUTPUT);
digitalWrite(in1,HIGH);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(in1, LOW);
Serial.println(digitalRead(5));
delay(5000);
digitalWrite(in1, HIGH);
Serial.println(digitalRead(5));
delay(5000);
}
With my multimeter, I can see that pin 5 is operating properly and outputting 0 Volts and 5 Volts when low and high, respectively. I can also see that the optocoupler is functioning, but I'm not sure if I have it hooked up correctly. I've tried hooking pin 8 of the optocoupler to the 12V power supply and also not hooking it to the 12V power supply. I've also tried running the 12V power supply through pin 6 of the optocoupler.
I know my breadboard picture isn't great, but I did try to print out the instructables sheet and relabel the components and pin numbers with how I am assigning them and linking things together. Sorry it's handwritten.
Can anybody help me? I'm really stuck.
0334_001.pdf (40.6 KB)