This C++ code implements a speed control system using an IR remote with an Arduino board and a liquid crystal display (LCD). The system allows users to adjust the speed of DC motor connected to the Arduino's PWM pin based on the received IR remote signals.
- Arduino board
- IR receiver module
- IR remote
- Liquid crystal display (LCD)
- Bulb connected to PWM pin
LiquidCrystal.h
: A library for controlling LCDs.IRremote.h
: A library for receiving and decoding IR signals.
receiver
: Pin 10 (connected to IR receiver module)buld
: Pin 9 (connected to the bulb)- LCD Pins: (12, 11, 5, 4, 3, 2)
- The system initializes the LCD, sets up IR remote reception, and displays a startup message.
- The loop continuously checks for IR signals. Upon receiving signals:
- If the received signal corresponds to
code1
, the counter increments, adjusting the brightness level up. - If the received signal corresponds to
code2
, the counter decrements, adjusting the brightness level down.
- If the received signal corresponds to
- The counter value is bounded within the range [1, 5].
- Based on the counter value, the PWM value for the bulb is adjusted accordingly, and the corresponding status message is displayed on the LCD.
- 1: Dimmer Off
- 2: Dimmer On, Speed 1
- 3: Dimmer On, Speed 2
- 4: Dimmer On, Speed 3
- 5: Dimmer Max
- The PWM value is adjusted to control the brightness level of the bulb.
- IR remote signals
code1
andcode2
are used for increasing and decreasing the brightness levels, respectively.