Relay on/off

Hello,

I just want to test some relays using pro mini. the program i wrote is

int relay1 = A0;
int relay2 = A1;

// the setup function runs once when you press reset or power the board
void setup() {
  
 pinMode(relay1,OUTPUT);  
 pinMode(relay2,OUTPUT);
 delay(5000);
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
}

// the loop function runs over and over again forever
void loop() {
 
  digitalWrite(relay1, HIGH);
  digitalWrite(relay2, HIGH);  
  delay(5000);                 
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);  
  }

i just want to on relays for 5 sec and off for 5 sec, but when output pins A0, A1 once turn HIGH are not getting to LOW, i also tried using different pins pin 11 and pin 12 but i got same result

There are any number of relays out there. Some are just a relay, some have transistor drivers, some have optically coupled inputs, etc. There are 5V coils, 12V coils, DC coils, AC coils, etc. Which relays do you have?

are not getting to LOW

How do you know that? Are you measuring the pin's output voltage? Are the relays actuating at all (hear a click)? If you replace a relay with an LED (and resistor) does the LED turn on and off?

How are the relays wired? Please show a schematic or a clear photo of the wiring. Is the Pro Mini 5V or 3.3V?

The more information that you provide the better and faster you will get answers.

void loop() 
{
  digitalWrite(relay1, HIGH);
  digitalWrite(relay2, HIGH);  
  delay(5000);                 
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);  
}

What happens immediately after you set the 2 relay pins LOW ?

UKHeliBob, I missed that. And it is a mistake that I have done. :-*

groundFungus:
UKHeliBob, I missed that. And it is a mistake that I have done. :-*

I, of course, have never made that mistake :slight_smile:

I, of course, have never made that mistake :slight_smile:

I think a lot of us recognized that one immediately!

thanks for the replies but i solved it myself, i have to add a delay after the pins which are set LOW and it works