Op werkdagen vóór 14:00 uur besteld = dezelfde dag verzonden en in 98% van de gevallen de volgende dag in huis. Gratis retourneren 30 dagen bedenktijd 1 jaar garantie
← Tillbaka till översikten

Vid uppspelning laddas videon från YouTube.

Kopplingsschema och kodexempel

Så här kopplar du Relämodul 5v Low till en Arduino UNO eller ESP32, med ett exempel­sketch som du kan ladda upp direkt.

5V Active-Low Relay Control

This project demonstrates how to control a 5V active-low relay module with an Arduino Uno. The sketch toggles the relay ON and OFF every two seconds while printing the current state to the Serial Monitor. Because this is an active-low module, setting the control pin LOW activates the relay, and setting it HIGH deactivates it.

Kopplingsschema: Relämodul 5v Low på en Arduino UNO
Kopplingsschema · Klicka för att förstora
Kopplingstabell: Relämodul 5v Low på en Arduino UNO
Kopplingstabell · Klicka för att förstora
5V_Active_Low_Relay_Control.ino · kompilerad och testad
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : 5V Active-Low Relay Control
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : Relais Module 5v Low
 *  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.
 * ==================================================================
 */

// Pin configuration
const int relayPin = 7;

void setup() {
  // Set the relay pin as output
  pinMode(relayPin, OUTPUT);
  
  // Active-low relay: default to OFF (HIGH state)
  digitalWrite(relayPin, HIGH);

  Serial.begin(115200);
  while (!Serial) {
    ; // Wait for serial port to connect
  }

  Serial.println(F("5V Relay Module Demo Started"));
  Serial.println(F("Relay will toggle every 2 seconds."));
}

void loop() {
  // Turn relay ON (active LOW)
  Serial.println(F("Relay: ON"));
  digitalWrite(relayPin, LOW);
  delay(2000);

  // Turn relay OFF (HIGH)
  Serial.println(F("Relay: OFF"));
  digitalWrite(relayPin, HIGH);
  delay(2000);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

ESP32 5V Relay Control Demo

This example demonstrates how to control a 5V active-low relay module with the ESP32. The relay's coil is powered from the VIN pin (5V from USB) while GPIO 4 toggles the control pin. Driving the control pin LOW energizes the relay switch, and driving it HIGH turns it off.

Kopplingsschema: Relämodul 5v Low på en ESP32 DevKit V1
Kopplingsschema · Klicka för att förstora
Kopplingstabell: Relämodul 5v Low på en ESP32 DevKit V1
Kopplingstabell · Klicka för att förstora
ESP32_5V_Relay_Control_Demo.ino · kompilerad och testad
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : ESP32 5V Relay Control Demo
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : Relais Module 5v Low
 *  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.
 * ==================================================================
 */

// Pin connected to relay IN
const int RELAY_PIN = 4;

void setup() {
  Serial.begin(115200);
  
  // Configure relay pin as output and start with relay OFF (HIGH = inactive for active-low module)
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, HIGH);
  
  Serial.println("ESP32 Relay Module Demo Initialized");
}

void loop() {
  // Turn relay ON (Active-low: LOW energizes coil)
  Serial.println("Relay: ON");
  digitalWrite(RELAY_PIN, LOW);
  delay(2000);

  // Turn relay OFF (Active-low: HIGH de-energizes coil)
  Serial.println("Relay: OFF");
  digitalWrite(RELAY_PIN, HIGH);
  delay(2000);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online