Skip to content

About

IR remote-controlled 4-digit multiplexed 7-segment countdown timer on Arduino Uno

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

IR Remote Countdown Timer

A 4-digit, 7-segment countdown timer for the Arduino Uno, driven entirely by an IR remote. You key a number in digit-by-digit like a calculator, hit play, and it counts down one second per tick, flashing the display when it hits zero.

No driver ICs, no shift registers. The segments are multiplexed straight off the Uno's GPIO.

Hardware

Part Notes
Arduino Uno (ATmega328P) 5 V, 16 MHz
4-digit 7-segment display Common-anode, with decimal point
IR receiver VS1838B / TSOP-style, demodulated NEC output
IR remote Generic NEC remote (Elegoo/keyestudio "MP3 car" layout)
Resistors One per segment line

Pin map

Function #define Pin
Segment A A 6
Segment B B 2
Segment C C 10
Segment D D 12
Segment E E 13
Segment F F 5
Segment G G 9
Decimal point H 11
Digit 1 select D1 7
Digit 2 select D2 4
Digit 3 select D3 3
Digit 4 select D4 8
IR receiver IR_RECEIVE_PIN A0

The project needs 13 I/O lines but the Uno only has 12 clean digital pins free (0 and 1 are the hardware UART, used by Serial at 115200 baud for debugging). One line has to live on an analog pin, and it's deliberately the IR input — an input tolerates a weak or high-impedance pin, while a segment output on the same pin leaves the LED faintly lit instead of fully off.

Controls

Button Effect
0–9 Shift a digit into the value (num = num * 10 + digit)
+ / − Increment / decrement
▶‖ Start the countdown; press again to pause, and again to resume
EQ Reset to 0 (also works while paused)

How it works

Multiplexing. All four digits share one set of segment lines, so only one digit's pattern can be on the bus at a time. showDigit() blanks all four digit selects, writes the segment pattern, then enables exactly one digit. displayNumber() walks all four positions with a 1 ms hold, giving a ~4 ms frame (~250 Hz) — fast enough that persistence of vision makes it look continuous.

Active-low segments. The display is common-anode: the digit select is driven HIGH, and a segment lights when its pin is pulled LOW. The font table stores 1 = "on", so the code inverts it: digitalWrite(segPins[i], !digits[num][i]).

Waiting without going dark. A plain delay() stops the multiplex loop and blanks the display. pauseDisplay(ms) is a drop-in replacement that burns the same time by calling displayNumber() repeatedly, so the number stays visible while you wait.

IR decoding. The receiver demodulates the 38 kHz NEC carrier; IRremote.hpp decodes the frame and the sketch reads the 8-bit decodedIRData.command field. mapCodeToDigit() switches each button code to a meaning, returning -1 for anything unmapped.

Pausing. countdown() checks for an IR signal after every one-second tick. On play/pause it calls pause(), which keeps calling displayNumber() so the frozen number doesn't dim, and keeps decoding IR so digits, +/-, and EQ still work through the same applyInput() helper loop() uses. Play/pause again drops out of pause(), and countdown() resumes without also burning a decrement on the tick it spent paused.

Building

Needs the IRremote library (v3+, for the IRremote.hpp header). Install it via the Arduino IDE Library Manager, then open remote_timer.ino and upload to an Uno.

Known limitations

  • Decrementing at 0 underflows. num is unsigned long, so − wraps to a huge value and num %= 10000 leaves garbage. The guard checks input > 0 instead of num > 0.
  • There's no separate "cancel" button. To bail out of a countdown early, pause it, hit EQ to zero the value, then resume; countdown() sees num == 0 and exits right away.
  • The decimal point (H, pin 11) is set to OUTPUT but never explicitly driven off. Pin 11 is a Timer2 PWM pin, which makes it a candidate for stray glow.
  • Digit anodes are driven straight from GPIO, so a single pin sources the current for every lit segment in that digit. That can exceed the ~20 mA per-pin limit; a transistor per digit would be the right fix.
  • pow() is used for digit extraction, which pulls in floating-point math for what is integer division and modulo.
  • pauseDisplay() still busy-waits. A millis()-based state machine would let the timer, IR, and display run concurrently.

About

IR remote-controlled 4-digit multiplexed 7-segment countdown timer on Arduino Uno

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages