Esta publicação destina-se a iniciantes para interfacear placas de retransmissão com o Arduino. Veja abaixo os detalhes da conexão para conectar a placa de relé de 4 canais com o Arduino. Os relés são relés de 12V.
Os detalhes da placa de relé de 4 canais são dados abaixo.
• Connect VCC to 12V.
• Inputs 1,2,3 & 4 are used to control the corresponding relays.
• If input is high (5V), then connection is between C (Common) & NO (Normally Open), else connection is between C (Common) & NC (Normally Closed).
• If Input1 is high, LED1 glows and vice versa.
• This board has a ULN driver which gives better performance compared to transistor drive.
• ULN2003 has seven high current Darlington arrays each containing seven open collector Darlington pairs with common emittors.
PS : Make sure to short the ground of 12V and Arduino.
• Inputs 1,2,3 & 4 are used to control the corresponding relays.
• If input is high (5V), then connection is between C (Common) & NO (Normally Open), else connection is between C (Common) & NC (Normally Closed).
• If Input1 is high, LED1 glows and vice versa.
• This board has a ULN driver which gives better performance compared to transistor drive.
• ULN2003 has seven high current Darlington arrays each containing seven open collector Darlington pairs with common emittors.
PS : Make sure to short the ground of 12V and Arduino.
Given below is a sample code to operate the 4 channel relay board using Arduino.
Depending on the state of the pushbutton connected to pin 7 relays will be turned ON/OFF. If pin 7 is high, relays will be turned ON and vice versa.
// constants won’t change. They’re used here to
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int relay1 = 2; // the number of the relay1 pin
const int relay2 = 3;
const int relay3 = 4;
const int relay4 = 5;// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int relay1 = 2; // the number of the relay1 pin
const int relay2 = 3;
const int relay3 = 4;
const int relay4 = 5;// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the relay1,2,3,4 pins as an output:
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
// initialize the relay1,2,3,4 pins as an output:
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}
else {
// turn relays off:
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
}
}
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}
else {
// turn relays off:
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
}
}
Likewise the details of Single channel, 2-channel and 8-Channel relay boards are given below.
Single Channel Relay board.
Given below is a sample code to operate the single channel lay board using Arduino.
Single Channel Relay board.

// constants won’t change. They’re used here to
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int relay1 = 13; // the number of the relay1 pin// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int relay1 = 13; // the number of the relay1 pin// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the relay pin as an output:
pinMode(relay1, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
// initialize the relay pin as an output:
pinMode(relay1, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
}
else {
// turn relays off:
digitalWrite(relay1, LOW);
else {
// turn relays off:
digitalWrite(relay1, LOW);
}
}
}
Given below is a sample code to operate the 2 channel lay board using Arduino.
// constants won’t change. They’re used here to
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int relay1 = 12; // the number of the relay1 pin
const int relay2 = 13;// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int relay1 = 12; // the number of the relay1 pin
const int relay2 = 13;// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the relay1,2 pins as an output:
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
// initialize the relay1,2 pins as an output:
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
}
else {
// turn relays off:
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
}
}
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
}
else {
// turn relays off:
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
}
}
Given below is a sample code to operate the 8 channel relay board using Arduino.
// constants won’t change. They’re used here to
// set pin numbers:
const int buttonPin = 8; // the number of the pushbutton pin
const int relay1 = 0; // the number of the relay1 pin
const int relay2 = 1;
const int relay3 = 2;
const int relay4 = 3;
const int relay5 = 4;
const int relay6 = 5;
const int relay7 = 6;
const int relay8 = 7;// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// set pin numbers:
const int buttonPin = 8; // the number of the pushbutton pin
const int relay1 = 0; // the number of the relay1 pin
const int relay2 = 1;
const int relay3 = 2;
const int relay4 = 3;
const int relay5 = 4;
const int relay6 = 5;
const int relay7 = 6;
const int relay8 = 7;// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the relay1,2,3,4 pins as an output:
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
pinMode(relay7, OUTPUT);
pinMode(relay8, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
// initialize the relay1,2,3,4 pins as an output:
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
pinMode(relay7, OUTPUT);
pinMode(relay8, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
digitalWrite(relay5, HIGH);
digitalWrite(relay6, HIGH);
digitalWrite(relay7, HIGH);
digitalWrite(relay8, HIGH);
}
else {
// turn relays off:
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
digitalWrite(relay5, LOW);
digitalWrite(relay6, LOW);
digitalWrite(relay7, LOW);
digitalWrite(relay8, LOW);
}
}
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn relays on:
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
digitalWrite(relay5, HIGH);
digitalWrite(relay6, HIGH);
digitalWrite(relay7, HIGH);
digitalWrite(relay8, HIGH);
}
else {
// turn relays off:
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
digitalWrite(relay5, LOW);
digitalWrite(relay6, LOW);
digitalWrite(relay7, LOW);
digitalWrite(relay8, LOW);
}
}

• Connect VCC to 12V.
• Inputs 1 to 8 are used to control the corresponding relays.
• If input is high(5V) , then connection is between C (Common) & NO (Normally Open), else connection is between C (Common) & NC (Normally Closed).
• If Input1 is high, LED1 glows and vice versa.
• Provision is left for connecting AC supply.
• This board has a ULN driver which gives better performance compared to transistor drive.
• The ULN2803A device is a high-voltage, high-current Darlington transistor array. The device consists of eight npn Darlington pairs that feature high-voltageoutputs with common-cathode clamp diodes for switching inductive loads.
0 Comentários:
Postar um comentário
Assinar Postar comentários [Atom]
<< Página inicial