

My project is about blinking or switching an led with Ir proximity sensor, button and potentiometer for adjusting the brightness of an led.
I made this project for understanding the serial communication.
Interactive Serial Control and Sensor Fusion
This project explores the concept of "Sensor Fusion" and interactive serial control. Instead of a hard-coded behavior, this system allows the user to dynamically enable or disable different input devices (IR sensor, Buttons, or Potentiometer) via software commands, demonstrating a sophisticated level of communication between a computer and the Arduino.
Hardware Interfacing
- Sharp IR Proximity Sensor: An analog sensor that measures distance by triangulation. It is highly effective within a 10-80cm range. In this project, it acts as a non-contact toggle for the LED.
- Rotary Potentiometer: Used for Pulse Width Modulation (PWM) control. By rotating the knob, you adjust the duty cycle of the signal sent to the LED, effectively dimming or brightening it.
- Tactile Buttons: Provide a familiar, physical interface for manual control.
Serial Command Logic and Implementation
The project utilizes the Arduino's Serial Buffer to listen for specific strings:
- Command 'ir' / '!ir': Toggles the proximity logic. When enabled, the Arduino continuously checks the analog value from the Sharp sensor. If it detects an object within the specific threshold, it toggles the LED state.
- Command 'bt' / '!bt': Enables or disables the physical buttons.
- Command 'pot' / '!pot': Activates the brightness control mode. When active, the
analogRead()value from the potentiometer is mapped to ananalogWrite()range (0-255) for the LED pin.
This structure allows for a modular code design where each component's behavior is encapsulated and controlled by a central "command listener," making the system highly flexible for future expansions.
The effective distance measuring range for this proximity sensor is 10-80cm. If an object is closer than the shortest distance, it reports a significantly higher analog output and is inconsistent with expected in-range results. For example, when an object is 1 cm away from the sensor, it reports an analogRead() value of 322. However, when the object is 5 cm away, the output is 655.for adjusting led's brightness I added one more button and by pressing only you can adjust the brightness.
It works by Serial communication....when you send 'ir', the Ir sensor is enabled, when you send '!ir', the Ir sensor is disabled. like the same way when you send 'bt' or '!bt' the button is enables or disabled respectively and the pot also send 'pot' or '!pot' the potentiometer is enabled or disabled respectively.
When button or the sensor or the potentiometer is enabled it shows 'ir enabled' or 'bt enabled' in the Serial monitor and when any of these are disabled it shows 'ir disabled' or 'bt disabled'.