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

Arduino UNO Controlled DC Motor with IR and Tilt Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled DC Motor with IR and Tilt Sensors

Circuit Documentation

Summary

The circuit in question is designed to interface an Arduino UNO with a pair of IR sensors, a tilt sensor, and a DC motor via an L298N motor driver. The Arduino UNO reads inputs from the IR and tilt sensors to determine environmental conditions and controls the motor accordingly. The IR sensors detect the presence or absence of objects, while the tilt sensor provides positional feedback. The motor driver facilitates the control of the motor's direction and speed.

Component List

Arduino UNO

L298N DC Motor Driver

Gearmotor DC / Motorreductor

IR Sensor

Tilt Sensor

Wiring Details

Arduino UNO

L298N DC Motor Driver

Gearmotor DC / Motorreductor

IR Sensor

Tilt Sensor

Documented Code

int irSensor1 = 6; 
int irSensor2 = 7; 
int tiltSensor = 2;

bool OnlyOneIR = false;   
bool IsTilt = false; 

void setup() {
  pinMode(irSensor1, INPUT);
  pinMode(irSensor2, INPUT);
  pinMode(tiltSensor, INPUT);

  Serial.begin(9600);
}

void loop() {
  
  int irSensor1Value = digitalRead(irSensor1);
  int irSensor2Value = digitalRead(irSensor2);
  int tiltSensorValue = digitalRead(tiltSensor);

  Serial.print("IR Sensor 1: ");
  Serial.println(irSensor1Value);
  Serial.print("IR Sensor 2: ");
  Serial.println(irSensor2Value);
  Serial.print("Tilt Sensor: ");
  Serial.println(tiltSensorValue);
 
 if (tiltSensorValue == 1) {
    IsTilt = true;
  } else {
    IsTilt = false;
  }
 if ((irSensor1Value == 1 && irSensor2Value == 0) || (irSensor1Value == 0 && irSensor2Value == 1)) {
    OnlyOneIR = true;
  } else {
    OnlyOneIR = false;
  }

 Serial.print("IsTilt: ");
  Serial.println(IsTilt);

 Serial.print("OnlyOneIR: ");
  Serial.println(OnlyOneIR);

}

The code is written for the Arduino UNO and is responsible for reading the state of the IR and tilt sensors. It prints the status of each sensor to the serial monitor and determines if only one IR sensor is triggered or if the tilt sensor is activated.