Search Code

Code Arduino mpe Vidéo ya Relay ya Ba-Chaine mibale ya 5V

Code Arduino mpe Vidéo ya Relay ya Ba-Chaine mibale ya 5V

Na boyekoli oyo, tokoyekola ndenge ya kokamba ba AC mpe DC na nzela ya relé ya ba canal mibale ya 5V na Arduino. Relé yango epesaka yo nzela ya kosala échange kati na ba charges mibale, lokola ampoule ya AC mpe moteur ya DC, mpe epesaka yo possibilité ya kosalela yango na ba applications ndenge na ndenge. Na suka ya boyekoli oyo, okokoka kotia système ya relé na yo moko mpe kokamba yango na code ya Arduino ya pete.

2 chanel relay module

Na boumeli ya processus oyo, tokolobela ba composants oyo esengeli, ba instructions ya câblage, mpe ndenge ya kosala na code ya Arduino oyo esalelami mpo na kokamba relé. Projet oyo ezali malamu mpo na ba débutants oyo balingi koyeba mokili ya électronique mpe automatisation. Mpo na bokambi ya visual, tala vidéo oyo elandi (na vidéo na 00:00).

Explication ya Hardware

Composant principal na projet oyo ezali relé ya ba canal mibale ya 5V. Relé oyo ezali na ba interrupteurs mibale ya indépendant oyo ekoki kokamba ba charges séparées. Chaque relé ezali na ba contacts misato: Normalement Fermé (NC), Normalement Ouvert (NO), mpe Commun (COM). Tango relé e activé, contact NO ekangami, mpe yango epesaka courant nzela ya kosala na charge.

Ba composants mosusu ya ntina ezali carte Arduino, oyo ekokamba relé na nzela ya ba pins na yango ya digital. Module ya relé ezali mpe na ba LED ya indicateur oyo e pelaka tango relé e activé. Na libanda, relé ezali isolé na optique, mpe yango epesaka sécurité na séparation ya circuit ya contrôle na circuit ya charge.

Détails ya Datasheet

FabricantSongle
Numéro ya pièceSRD-05VDC-SL-C
Tension ya Logic/IO5 V
Tension ya alimentation5 V
Courant ya sortie (na canal)10 A
Courant ya pointe (na canal)10 A
Guidance ya fréquence PWMN/A
Seuils ya logique ya entrée2.5 V min
Chute ya tension / RDS(on) / saturation80 mΩ
Limites thermiques70 °C
PackageModule
Notes / variantesIsolé optiquement

  • Kokanola isolation ya malamu tango okoki kosangisa ba charges ya AC.
  • Salela ba fusibles ya malamu mpo na sécurité na ba charges ya makasi.
  • Keba ete module ya relé ezala mosika na mayi.
  • Kanola heatsinking mpo na ba applications ya puissance ya makasi.
  • Vérifier câblage liboso ya kopelisa mpo na kokima dégâts.
  • Salela ba alimentations séparées mpo na ba appareils ya courant ya makasi soki esengeli.

Instructions ya Câblage

Arduino wiring for 2 channel relay module AC load
Arduino wiring for 2 channel relay module AC load

Mpo na kosangisa relé ya ba canal mibale na Arduino, banda na kokangisa pin ya VCC ya module ya relé na pin ya 5V na Arduino. Kokangisa pin ya GND ya relé na pin ya GND na Arduino. Oyo epesaka puissance na module ya relé.

Na sima, kokangisa ba pins ya contrôle: kokangisa pin ya IN1 ya relé na pin ya digital 7 na Arduino mpe pin ya IN2 na pin ya digital 8. Configuration oyo ekopesa yo nzela ya kokamba ba relé mibale na ndenge ya indépendant. Na suka, kokangisa ba charges na yo ya AC to DC na ba contacts ya relé kolanda mposa na yo, mpe kolanda ba précautions ya sécurité tango ozali kosala na tension ya AC.

Ba Exemples ya Code mpe Explication

Na code ya Arduino, tobandi na initialisation ya communication série mpe na kopesa ba modes ya pins mpo na ba pins ya contrôle ya relé. Ba variables relay1Pin mpe relay2Pin e définis mpo na kopesa ba pins oyo esangani na chaque relé. Ba états ya sortie ya ba pins oyo etikali e changé na boucle.

const int relay1Pin = 7; // définir pin mpo na relé 1
const int relay2Pin = 8; // définir pin mpo na relé 2

void setup() {
  Serial.begin(9600); // configuration ya Serial Monitor mpo na kolakisa information
  pinMode(relay1Pin, OUTPUT); // esangani na Relé 1
  pinMode(relay2Pin, OUTPUT); // esangani na Relé 2
}

Extrait oyo e initialise moniteur série mpo na kobimisa information ya débogage mpe e kopesa ba pins ya contrôle ya relé lokola ba sorties. Oyo ezali ya ntina mingi mpo na kokanola ete ba relé ekoki kopelama mpe kozimama kolanda mposa.

void loop() {
  digitalWrite(relay2Pin, LOW); // zongisa relé 2 OFF 
  Serial.print("Pin 8 LOW");
  digitalWrite(relay1Pin, HIGH); // pelisa relé 1 ON
  Serial.println(" Pin 7 HIGH");
  delay(3000); // keba na relé 2 OFF mpe relé 1 ON mpo na secondes 3
  digitalWrite(relay1Pin, LOW); // zongisa relé 1 OFF
  digitalWrite(relay2Pin, HIGH); // pelisa relé 2 ON
  Serial.print("Pin 7 LOW");
  Serial.println(" Pin 8 HIGH");
  delay(3000); // keba na relé 1 OFF mpe relé 2 ON mpo na secondes 3
}

Code oyo e changé ba relé na boucle ya secondes misato, mpe e pelisaka moko na tango oyo e zongisaka mosusu. Moniteur série e bimisaka état ya ba pins, mpe yango esalisaka na débogage mpe na koyeba ndenge relé ezali kosala.

Démonstration / Nini Okokanola

Tango configuration esili, okomona relé e changé kati na ba charges oyo esangani na secondes misato na misato. Relé e activer ampoule ya AC to moteur ya DC na ndenge ya alternance. Keba mingi tango ozali kosala na ba charges ya AC, pamba te kosala malamu te ekoki komema na ba situations ya likama (na vidéo na 12:34).

Ba Timestamps ya Vidéo

  • 00:00 - Introduction na relé ya ba canal mibale
  • 04:15 - Instructions ya câblage
  • 08:30 - Explication ya code
  • 10:45 - Démonstration ya relé

Images

Arduino wiring for 2 channel relay module AC load
Arduino wiring for 2 channel relay module AC load
2 chanel relay module
2 chanel relay module
2 chanel relay module
2 chanel relay module
2 chanel relay module
2 chanel relay module
2 chanel relay module
2 chanel relay module
46-This is the Arduino code for a dual-channel 5V relay.
Langue: C++
/*
 * This is the Arduino code for Dual Channel 5V Relay
 * to control turning ON or OFF AC or DC loads. You can control 2 different loads such as bulbs, or a heater, or other machines.
  Watch the video instruction for this code: https://youtu.be/EclIomn_3dI
 
 *  * 
 * Written by Ahmad Shamshiri for Robojax Video
 * Date: December 26, 2017, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purposes only.
 


Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all materials, wiring diagrams and libraries
all in one place. Purchase my course on Udemy.com: http://robojax.com/L/?id=62

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon: http://robojax.com/L/?id=63

or make a donation using PayPal: http://robojax.com/L/?id=64


 * 
  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been downloaded from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

 


void setup() {
  
  Serial.begin(9600);// setup Serial Monitor to display information
  pinMode(7, OUTPUT);// connected to Relay 1
  pinMode(8, OUTPUT);// connected to Relay 2

}

void loop() {
  digitalWrite(8, LOW); // turn relay 2 OFF 
      Serial.print("Pin 8 LOW");
  digitalWrite(7,HIGH);// turn relay 1 ON
      Serial.println(" Pin 7 HIGH");
  delay(3000);// keep in relay 2 OFF and relay 1 On for 3 seconds
  digitalWrite(7, LOW);// turn relay 1 OFF
  digitalWrite(8,HIGH);// turn relay 2 ON
      Serial.print("Pin 7 LOW");
      Serial.println(" Pin 8 HIGH");
  delay(3000);// keep in relay 1 OFF and relay 2 On for 3 seconds


}
47-Control AC loads using a 2-channel relay and an Arduino
Langue: C++
/*
 * This is the Arduino code for a dual-channel 5V relay
 * to control turning ON or OFF AC or DC loads. You can control 2 different loads such as bulbs, a heater, or other machines.
 Watch the video instruction for this code: https://youtu.be/EclIomn_3dI
 
 *  * 
 * Written by Ahmad Shamshiri for Robojax Video
 * Date: December 26, 2017, in Ajax, Ontario, Canada
 * Permission granted to share this code, given that this
 * note is kept with the code.
 * Disclaimer: This code is "AS IS" and for educational purposes only.
 


Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all materials, wiring diagrams, and libraries
all in one place. Purchase my course on Udemy.com: http://robojax.com/L/?id=62

If you find this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon: http://robojax.com/L/?id=63

or make a donation using PayPal: http://robojax.com/L/?id=64


 * 
  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.
 * This code has been downloaded from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

const int relay1Pin =7;// define pin for relay 1
const int relay2Pin =8; // define pin for relay 2


void setup() {
  
  Serial.begin(9600);// setup Serial Monitor to display information
  pinMode(relay1Pin, OUTPUT);// connected to Relay 1
  pinMode(relay2Pin, OUTPUT);// connected to Relay 2

}

void loop() {
  digitalWrite(relay2Pin, LOW); // turn relay 2 OFF 
      Serial.print("Pin 8 LOW");
  digitalWrite(relay1Pin,HIGH);// turn relay 1 ON
      Serial.println(" Pin 7 HIGH");
  delay(3000);// keep in relay 2 OFF and relay 1 On for 3 seconds
  digitalWrite(relay1Pin, LOW);// turn relay 1 OFF
  digitalWrite(relay2Pin,HIGH);// turn relay 2 ON
      Serial.print("Pin 7 LOW");
      Serial.println(" Pin 8 HIGH");
  delay(3000);// keep in relay 1 OFF and relay 2 On for 3 seconds


}

Nko o na nki.

Mokili na bisika

Pas encore de ressources.

Fichiers📁

Aucun fichier disponible.