Hello,
I am a new in the electronic domain. In my work, I am trying to control 4 infrared light sources. I got an arduino uno microcontrollor and relay shield v2.0 that contains 4 relays.
I connect my arduino with the relay shield and I upload this program in my arduino.
// On the relay v2.0, the 4 relays are controlled by the 4 following pins.
// these pins correpond to the same 4 pins on the Arduino Uno micro controller.
/*
relay 1---> pin 7.
relay 2---> pin 6.
relay 3---> pin 5.
relay 4---> pin 4.
*/
int light1=7; // Arduino pin 7 to control light1 connected to the relay 1.
int light2=6; // Arduino pin 6 to control ligh2 connected to the relay 2.
int light3=5; // Arduino pin 5 to control light3 connected to the relay 3.
int light4=4; // Arduino pin 4 to control ligh4 connected to the relay 4.
// the setup routine runs once when you press reset:
void setup()
{
// declare pin 7 to be an output to control the relay 1 and consequently the ligh1.
pinMode(light1,OUTPUT);
pinMode(light2,OUTPUT);
pinMode(light3,OUTPUT);
pinMode(light4,OUTPUT);
}
// the loop routine runs over and over again forever:
void loop()
{
//------------------------light1------------------------
digitalWrite(light1,HIGH);// NO1 and COM1 Connected;
delay (1000);
digitalWrite(light1,LOW);// NO1 and COM1 Disconnected;
//------------------------light2------------------------
digitalWrite(light2,HIGH);// NO2 and COM2 Connected;
delay (1000);
digitalWrite(light2,LOW);// NO2 and COM2 Disconnected;
//------------------------light3------------------------
digitalWrite(light3,HIGH);// NO3 and COM3 Connected;
delay (1000);
digitalWrite(light3,LOW);// NO3 and COM3 Disconnected;
//------------------------light4------------------------
digitalWrite(light4,HIGH);// NO4 and COM4 Connected;
delay (1000);
digitalWrite(light4,LOW);// NO4 and COM4 Disconnected;
}
// end program
After uploading this program, I see that 4 Led are turn each 1000 ms (delay (1000)) but rely did not click (no noise like tic-tac for on off between COM_i and NO_i)
After that, I try just to control one light source using the arduino and the relay.
I connect the light source positive wire directly in the battery (12v) and I connect the negative wire to COM1 and NO1 and then to battery.
I upload this programm:
/*
relay 1---> pin 7.
relay 2---> pin 6.
relay 3---> pin 5.
relay 4---> pin 4.
*/
int light1=7; // Arduino pin 7 to control light1 connected to the relay 1.
int light2=6; // Arduino pin 6 to control ligh2 connected to the relay 2.
int light3=5; // Arduino pin 5 to control light3 connected to the relay 3.
int light4=4; // Arduino pin 4 to control ligh4 connected to the relay 4.
// the setup routine runs once when you press reset:
void setup()
{
// declare pin 7 to be an output to control the relay 1 and consequently the ligh1.
pinMode(light1,OUTPUT);
pinMode(light2,OUTPUT);
pinMode(light3,OUTPUT);
pinMode(light4,OUTPUT);
}
// the loop routine runs over and over again forever:
void loop()
{
//------------------------light1------------------------
digitalWrite(light1,HIGH);// NO1 and COM1 Connected;
//delay (1000);
//digitalWrite(light1,LOW);// NO1 and COM1 Disconnected;
}
The light source did not work. Note that the light source is very good.
Any help please!