To enhance my knowledge of the sensors and components I'll be using in my final project, I decided that this week's assignment should contribute to the project's development. My project will be a card shuffler and dealer, so I built the circuit for the shuffling part.
The goal is that when the IR sensor detects card movement after the switch is turned on, the motor and LED should activate. When the sensor detects no movement, they should stop working.
FOR Simulation Circuit
To simulate the circuit and ensure it works with the correct connections.
Electronics Tools
Breadboard
Dc Motor
Jumpers Wires
Arduino Uno
Slide Switch
Leds
Resisotrs
IR Sensor
Design Circuit on Tinkercad:
Circuit Components:
One LEDs
DC motor
Slide switch (functions as an on/off switch)
IR Sensor
Circuit Input:
Switch
Ir Sensor
Circuit Actions:
Movement
LED illumination
Steps Taken:
Connected the motor to the switch
Connected the LEDs and slide switch
Connected IR sensor
Connected all Component with Arduino
Finally Code blocks
Code :
This code controls an LED and a DC motor based on input from a slide switch and an IR sensor. Here's a detailed explanation of how it works:
Reading the Slide Switch (Pin 2):
The code first checks if the slide switch is turned ON (HIGH) on Pin 2.
If the switch is OFF (LOW), nothing will turn on, and both the LED and motor will remain OFF.
Reading the IR Sensor (Pin 5):
If the slide switch is ON, the code then checks the status of the IR sensor connected to Pin 5.
If the IR sensor detects an object (or meets a certain condition), it will send a HIGH signal.
Turning ON the LED and Motor (Pins 3 and 4):
If both the slide switch (Pin 2) and the IR sensor (Pin 5) are HIGH, the LED and DC motor (connected to Pin 3 and Pin 4) will turn ON.
Turning OFF the LED and Motor:
If either the slide switch or the IR sensor is LOW, the LED and motor will turn OFF by setting Pin 3 and Pin 4 to LOW.
Build Circuit on physical Breadboard
I made the connection after ensuring that the wiring was correct on Tinkercad. I first simulated the circuit by connecting the slide switch, IR sensor, LED, and DC motor to the Arduino board in Tinkercad. After verifying that the circuit functioned as expected, I proceeded with the physical implementation.
I uploaded the code as text to the Arduino software (Arduino IDE) by writing the necessary logic to read the switch and sensor inputs and control the LED and motor outputs accordingly. I then compiled and uploaded the code to the Arduino board. After running the circuit, I tested its functionality by toggling the switch and triggering the IR sensor to confirm that the LED and motor responded correctly.
Title of Media
Problem in making
One of the problems I faced was that the IR sensor's positive and negative terminals in reality were different from those on Tinkercad. I made the wrong connection and noticed the mistake when the sensor didn’t light up. When I touched it, it was extremely hot.
Another problem was that I forgot the breadboard's positive and negative rails are separated in the middle. I connected the resistor to the other side of the negative rail and was confused about why the LED wasn't lighting up. I only discovered this issue when I used the multimeter.
IR sensor in Tinkercad
IR Sensor in real
Title of Media