Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Touch-Activated Relay with LED Indicator

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Touch-Activated Relay with LED Indicator

Circuit Documentation

Summary of the Circuit

This circuit is designed to control a DC motor and an LED using an Arduino UNO microcontroller in response to input from a touch sensor. The motor is powered by a 9V battery and switched on and off by a 5V relay. The relay is controlled by the Arduino, which also directly controls the LED. The touch sensor provides a user interface to toggle the state of the motor and the LED.

Component List

Arduino UNO

9V Battery

5V Relay

DC Motor

Touch Sensor TTP233

LED: Two Pin (red)

Wiring Details

Arduino UNO

9V Battery

5V Relay

DC Motor

Touch Sensor TTP233

LED: Two Pin (red)

Documented Code

// Code for controlling a DC motor and LED using a touch sensor
const int relay1 = 8; // Relay control pin
const int led = 9;    // LED control pin
const int touchSensor = 7; // Touch sensor input pin

void setup() {
  pinMode(relay1, OUTPUT); // Set relay pin as output
  pinMode(led, OUTPUT);    // Set LED pin as output
  pinMode(touchSensor, INPUT); // Set touch sensor pin as input
  digitalWrite(relay1, HIGH); // Initialize relay as off
  digitalWrite(led, LOW);     // Initialize LED as off
}

void loop() {
  int sensorValue = digitalRead(touchSensor); // Read the touch sensor value

  if (sensorValue == HIGH) {
    // If the touch sensor is touched
    digitalWrite(relay1, LOW); // Turn on the relay (motor on)
    digitalWrite(led, HIGH);   // Turn on the LED
  } else {
    // If the touch sensor is not touched
    digitalWrite(relay1, HIGH); // Turn off the relay (motor off)
    digitalWrite(led, LOW);     // Turn off the LED
  }

  delay(100); // Small delay to debounce the touch sensor
}

This code is designed to run on the Arduino UNO microcontroller. It initializes the relay, LED, and touch sensor pins. In the main loop, it reads the state of the touch sensor. If the sensor is touched, it activates the relay (which turns on the motor) and the LED. If the sensor is not touched, it deactivates the relay and the LED. The delay at the end of the loop helps to debounce the touch sensor input.