SKU: OT961-C105 Numéro d’article: YP924 EAN: 4639867568390
Termes de recherche : relais 5v, relais 5v, relay 5v, 5v relay, relais haut, relais high, relay high, relais bleu, relais bleu, relais 250v, relais 220v, relais pour arduino, relais arduino, relais breadboard
Dimensions
Longueur : 3,3cm
Largeur : 2,6cm
Hauteur : 1,7cm
Voici comment connecter le Module relais 5 V pour Arduino à un Arduino UNO ou à un ESP32, avec un exemple de sketch que tu peux téléverser directement.
Ce projet montre comment contrôler un module relais 5V avec un Arduino UNO. Le sketch bascule le relais sur ON et OFF toutes les deux secondes tout en affichant l’état dans le Serial Monitor. Vous entendrez un clic audible du relais à chaque changement d’état.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : Control a 5V Relay with Arduino UNO
* Board : Arduino UNO (arduino:avr:uno)
* Parts : Relay Module 5V
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
// 5V Relay Module Example
const int RELAY_PIN = 7;
void setup() {
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(115200);
Serial.println(F("Relay module demo started."));
}
void loop() {
// Turn relay ON
digitalWrite(RELAY_PIN, HIGH);
Serial.println(F("Relay: ON"));
delay(2000);
// Turn relay OFF
digitalWrite(RELAY_PIN, LOW);
Serial.println(F("Relay: OFF"));
delay(2000);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online
Ce projet montre comment contrôler un module relais 5V à l’aide d’un ESP32. Le relais s’active et se désactive toutes les deux secondes tout en affichant son état dans le Serial Monitor. Le relais est alimenté directement depuis la broche VIN de l’ESP32 (5V via USB) et déclenché via GPIO 4.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : 5V Relay Control with ESP32
* Board : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
* Parts : Relay Module 5V
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
// 5V Relay Control Example for ESP32
const int RELAY_PIN = 4;
void setup() {
Serial.begin(115200);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
Serial.println("Relay control initialized.");
}
void loop() {
// Turn relay ON (Active HIGH for standard modules)
Serial.println("Relay: ON");
digitalWrite(RELAY_PIN, HIGH);
delay(2000);
// Turn relay OFF
Serial.println("Relay: OFF");
digitalWrite(RELAY_PIN, LOW);
delay(2000);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online