This circuit is designed for human detection and fan control using an Arduino UNO, an LD2410C sensor, a 1 Channel Relay, and a fan. The LD2410C sensor detects human presence and sends a signal to the Arduino UNO, which then activates the relay to turn on the fan. The circuit is powered by an AC supply, which is converted to DC using an HLK-PM12 module.
Arduino UNO
1 Channel Relay 5V
HLK-PM12
LD2410C
Fan
AC Supply
/*
* Arduino Sketch for Human Detection and Fan Control
*
* This code interfaces with an LD2410C sensor to detect human presence. When
* a human is detected, it activates a relay to turn on a fan. The relay is
* connected to digital pin 8 of the Arduino UNO, and the LD2410C sensor is
* connected to the Arduino's 3.3V, GND, RX (D1), and TX (D0) pins.
*/
#define RELAY_PIN 8
void setup() {
// Initialize serial communication for LD2410C
Serial.begin(9600);
// Set relay pin as output
pinMode(RELAY_PIN, OUTPUT);
// Ensure the relay is off initially
digitalWrite(RELAY_PIN, LOW);
}
void loop() {
// Check if data is available from LD2410C
if (Serial.available() > 0) {
// Read the incoming byte
char incomingByte = Serial.read();
// Check if the incoming byte indicates human presence
if (incomingByte == '1') { // Assuming '1' indicates presence
digitalWrite(RELAY_PIN, HIGH); // Turn on the relay (and the fan)
} else {
digitalWrite(RELAY_PIN, LOW); // Turn off the relay (and the fan)
}
}
}
This code initializes the serial communication for the LD2410C sensor and sets the relay pin as an output. In the main loop, it checks for incoming data from the sensor. If the data indicates human presence (assumed to be '1'), it turns on the relay, thereby activating the fan. If no presence is detected, it turns off the relay, deactivating the fan.