Unit 6: Intelligent Systems
I. Orientation
An intelligent system combines sensing, processing, decision-making, and action to respond to changes in its environment. In this unit, an Arduino Uno acts as the programmable controller, while an infrared (IR) sensor detects the presence or absence of an object. The system follows a basic closed-loop sequence: the sensor obtains input, the Arduino interprets it, and an output device such as an LED, buzzer, or motor indicates the decision.
- Sensing: An IR sensor converts reflected or interrupted infrared radiation into an electrical signal.
- Processing: The Arduino Uno reads the sensor signal through a digital or analog input pin.
- Decision-making: A program compares the input with a condition such as
object detected. - Actuation: An LED, buzzer, relay, or motor responds to the decision.
- Embedded control: The program executes repeatedly inside the Arduino’s
loop()function. - Logic convention: A sensor module may produce either
HIGHorLOWwhen an object is detected; this must be verified from the module or by testing. - Electrical reference: All connected devices must share a common ground, or
GND, so that voltage levels have the same reference. - Power condition: The Arduino Uno commonly operates at 5 V logic, while the sensor must be supplied within the voltage range specified for its module.
- Feedback principle: The output shows the system’s interpretation of the input, allowing the user to observe whether detection is working.
II. Arduino Uno and IR Sensor-Based Detection System — Design and Implementation
An Arduino Uno and IR sensor-based detection system is a small intelligent control system that detects an object and produces a programmed response. Its operation depends on the IR transmitter emitting infrared light and the receiver sensing the reflected light or a change caused by an object entering the detection region.
A. Design and implementation of an Arduino Uno and IR sensor-based detection system
This subsection explains the complete design, from identifying the blocks of the system to wiring, programming, and verification.
- System objective: The system detects a nearby object and switches an indicator.
- A typical response is to turn an LED on and sound a buzzer when an object is detected.
- The detection distance is adjusted using the small potentiometer provided on many IR obstacle-sensor modules.
- Functional blocks: The system contains four connected stages.
- Input: IR sensor module.
- Controller: Arduino Uno microcontroller board.
- Output: LED and/or buzzer.
- Power: 5 V supply and common ground.
- Operating principle: The IR transmitter emits modulated or continuous infrared radiation, commonly near 940 nm.
- Reflective detection: An object reflects IR radiation toward the receiver.
- Receiver response: A photodiode or phototransistor changes its electrical behavior according to received IR intensity.
- Comparator action: On many modules, an LM393 comparator compares the receiver signal with an adjustable reference and produces a digital output.
- Arduino Uno characteristics: The Uno is based on the ATmega328P microcontroller.
- It provides digital input/output pins
0to13. - Analog input pins
A0toA5can measure analog voltages using a 10-bit analog-to-digital converter. - Digital pins operate with 5 V logic in the standard Uno board.
- USB connects the board to the Arduino Integrated Development Environment, or IDE, for program upload and serial monitoring.
- It provides digital input/output pins
- Required components: A basic prototype needs the following hardware.
- Arduino Uno board.
- IR obstacle or proximity sensor module.
- LED, such as a 5 mm red LED.
- Current-limiting resistor, typically
220 ohmsto330 ohms. - Active buzzer, if audible indication is required.
- Breadboard and jumper wires.
- USB cable and a suitable computer.
- Electrical connections: A reliable connection table prevents incorrect pin use.
- IR sensor
VCCconnects to Arduino5V. - IR sensor
GNDconnects to ArduinoGND. - IR sensor
OUTconnects to digital pin2. - LED anode, the longer lead, connects through a
220-ohmresistor to digital pin13, or to another chosen output pin. - LED cathode, the shorter lead, connects to
GND. - An active buzzer positive terminal connects to digital pin
8; its negative terminal connects toGND.
- IR sensor
- Resistor function: The LED resistor limits current and protects both the LED and the Arduino output pin.
- Using a 5 V supply, an LED forward voltage of approximately 2 V, and a target current of 10 mA gives:
R = (Vs - Vf) / I
R = (5 V - 2 V) / 0.010 A
R = 300 ohmsRis resistance,Vsis supply voltage,Vfis LED forward voltage, andIis LED current.- A standard
330-ohmresistor is a suitable practical choice.- Input logic: The program must match the sensor’s output convention.
- Some modules produce
LOWwhen an object is detected. - Other modules produce
HIGHwhen an object is detected. - The module’s indicator LED, datasheet, or a short serial-monitor test can identify the actual behavior.
- Program structure: The Arduino program follows the standard embedded sequence.
setup()runs once to configure pins and initialize communication.loop()runs continuously to read the sensor and control outputs.digitalRead()obtains a digital input state.digitalWrite()appliesHIGHorLOWto an output pin.- Representative Arduino program: The following example assumes that the IR module output is
LOWduring detection.
- Representative Arduino program: The following example assumes that the IR module output is
const int irPin = 2;
const int ledPin = 13;
const int buzzerPin = 8;
void setup() {
pinMode(irPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorState = digitalRead(irPin);
if (sensorState == LOW) {
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
Serial.println("Object detected");
} else {
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
Serial.println("No object");
}
delay(100);
}irPin,ledPin, andbuzzerPinare integer constants identifying Arduino pins.sensorStatestores the logic level read from the IR sensor.LOWrepresents approximately 0 V, whileHIGHrepresents a logic-high voltage near 5 V under normal Uno conditions.delay(100)pauses for 100 milliseconds, reducing excessively rapid serial messages and visible output flicker.- Program modification: If the sensor detects objects with
HIGH, the condition must be changed.
- Program modification: If the sensor detects objects with
if (sensorState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}- Only the detection condition changes; the wiring and output logic can remain the same.
- Upload procedure: The program is transferred to the board through the Arduino IDE.
- Select the correct board:
Arduino Uno. - Select the correct serial port.
- Compile or verify the sketch.
- Upload it using the IDE upload command.
- Observe the sensor and output indicators after upload completes.
- Initial hardware inspection: Testing should begin with power disconnected.
- Check LED polarity: the longer lead is normally the anode.
- Confirm that the sensor
VCCandGNDwires are not reversed. - Ensure the resistor is in series with the LED.
- Confirm that no jumper wire creates a direct short between
5VandGND.- Calibration: The sensor potentiometer sets the comparator threshold and therefore affects detection distance.
- Rotate it gradually while placing an object at the required distance.
- Use a non-reflective and a reflective object during adjustment.
- The onboard sensor LED commonly changes state when the output threshold is crossed.
- Detection performance depends on object color, surface reflectivity, angle, ambient light, and distance.
- Functional test: A simple test sequence confirms each stage.
- With no object present, record whether the output is inactive.
- Place an object within the calibrated range and check for LED or buzzer activation.
- Move the object away and verify that the output returns to its original state.
- Open the Serial Monitor at
9600 baudand compare printed messages with physical behavior.- Signal stability: IR sensors may switch repeatedly near the detection threshold.
- Cause: Small changes in distance or reflected light can make the comparator alternate between states.
- Remedy: Adjust the potentiometer, use a short delay, or require several identical readings before changing the output.
- Improved decision rule: A system can count stable readings rather than responding to one changing sample.
- Object detection versus distance measurement: A digital IR module generally reports a threshold decision, not an exact distance.
- Digital output: Indicates whether the reflected signal is above or below a set threshold.
- Analog output: If available, changes with received IR intensity but is affected by object properties and is not automatically a calibrated distance value.
- For accurate range measurement, a dedicated time-of-flight or calibrated distance sensor is more appropriate.
- Common faults and diagnosis: Fault-finding should proceed from power to input, program, and output.
- No sensor LED: Check
VCC,GND, supply voltage, and module orientation. - Output always active: Reduce sensitivity, inspect for strong nearby reflections, and verify whether the code uses the correct active logic.
- Output never active: Increase sensitivity, move the object closer, and check the
OUTconnection. - LED not glowing: Check polarity, resistor placement, selected output pin, and program execution.
- Buzzer silent: Confirm that it is an active buzzer; a passive buzzer usually requires a changing waveform generated with
tone(). - Serial output absent: Check USB connection, selected port, and matching baud rate.
- Design improvement: A more dependable system separates detection, decision, and output actions.
- The sensor-reading code should obtain the input.
- The decision code should define the detection condition.
- The output code should activate the indicator.
- Meaningful pin constants make the program easier to modify and reduce wiring errors.
- Electrical limitations: Arduino output pins should not directly drive high-current loads.
- A relay coil, motor, or lamp requires a transistor or MOSFET driver.
- A relay coil also needs a flyback diode to absorb the reverse voltage generated when the coil is switched off.
- The Arduino should not be expected to supply motor current from an I/O pin.
- Environmental limitations: IR detection is not equally reliable in every setting.
- Sunlight and strong lamps contain infrared energy that may interfere with the receiver.
- Dark, black, angled, or highly absorbent surfaces reflect less IR.
- Transparent or glossy surfaces can produce unexpected reflections.
- Mechanical mounting should keep the transmitter and receiver aligned and protected from vibration.
- Safety and reliability: Safe construction protects both the user and the circuit.
- Use low-voltage DC power during breadboard testing.
- Disconnect power before changing wiring.
- Avoid short circuits and do not exceed the rated current of any pin.
- Secure wires and components before placing the system near moving machinery.
- Applications and limitations: This detection arrangement is useful for simple presence decisions but must be selected according to the application.
- Applications: Object counting, line-following robots, obstacle warning, automatic doors, parking indicators, and conveyor sensing.
- Limitation: It cannot by itself identify object type, measure reliable distance, or distinguish multiple objects.
- Extension: Multiple IR sensors can be connected to separate input pins, while software can assign different actions to each detection zone.
- Intelligent behavior: Adding timing, counting, filtering, or communication transforms a basic sensor circuit into a more capable embedded decision system.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →