I'm new to electronics but I decided I want to try and build a simple circuit to control with my Adruino UNO R3.
I want to make a relay switch on and off programmatically with my UNO.
Here is my current code:
#define RELAY_PIN 2
void setup() {
pinMode(RELAY_PIN, OUTPUT);
}
void loop() {
digitalWrite(RELAY_PIN, LOW);
delay(2000);
digitalWrite(RELAY_PIN, HIGH);
delay(2000);
}
Here is the diagram of my current circuit:
The relay I'm using is a 12 V low level trigger relay (in diagram.)
The problem is when the IN1 wire is connected to pin 2 on the UNO, the relay buzzes consistently and doesn't open/close the circuit, but when I take the IN1 wire and put it into 12V- on the power supply, the relay opens/closes.
I watched a YouTube video where a BC547 transistor was used. I tried it (UNO D2 to base, IN1 to emitter) and no success as well.
How do I get the relay to work correctly?