ELE1001 — Digital Systems & Embedded

BCD Keypad Display & Pill Bottling System

A complete three-stage automated system combining Arduino-based user input with discrete digital logic for accurate pill counting and bottling control. Demonstrates microcontroller integration with TTL components in a real-world industrial application.

← Back to projects

General Objective

The objective of this project is to design an embedded digital system capable of reading a user-defined quantity through a 4×4 keypad, displaying that value in BCD on two seven-segment displays, and using this value to control an automated pill bottling process. The system must be reliable, deterministic, and compatible with downstream digital logic, combining discrete logic components with Arduino-based optimization for a modular and maintainable architecture.

System Architecture: Three Stages

1

User Input & Display

Arduino manages keypad scanning, BCD conversion, and seven-segment display control entirely in software.

2

Pill Counting

Cascaded BCD counters and magnitude comparator detect when the correct number of pills has been counted.

3

Bottle Counting

Modulo-8 counter tracks filled bottles (0–7) with seven-segment display and automatic wraparound detection.

1

Stage 1: User Input & Display (Arduino)

Keypad Reading

A 4×4 matrix keypad serves as the human-machine interface. The Arduino performs matrix scanning:

  • Columns are driven LOW one at a time
  • Rows are read using INPUT_PULLUP configuration
  • A key is detected when a row reads LOW while its column is active

Key Design Decision:

The system detects key release, not key press. This naturally eliminates switch bounce and prevents repeated inputs when a key is held—a crucial reliability improvement.

Conversion to BCD

When a numeric key (0–9) is released:

  • The key is converted to its BCD representation
  • The system automatically alternates between units and tens digits
  • An internal state variable handles this alternation

This design allows intuitive two-digit entry without additional confirmation steps.

BCD Output Generation

The Arduino drives eight dedicated GPIO pins:

Units Digit

4 pins for BCD representation (2⁰, 2¹, 2², 2³)

Tens Digit

4 pins for BCD representation (2⁰, 2¹, 2², 2³)

Each pin corresponds directly to one BCD bit, ensuring full compatibility with standard TTL components such as decoders and comparators.

Display Blanking with *

Pressing the * key blanks both displays by disabling all output pins.

  • All BCD lines are forced to a state that turns off the seven-segment displays
  • No display updates occur while blanked
  • Any valid numeric key automatically re-enables outputs

This feature improves usability by allowing visual reset without affecting internal logic.

Validation & Synchronization Signals

Z Signal

Each valid numeric entry generates a short pulse on the Z signal. This validates the digit entry to external counting logic, replacing what would otherwise require extra flip-flops and clock conditioning.

# Signal (Finalize)

Pressing # generates a dedicated control pulse that tells the counting system to begin a new cycle. It also copies the tens digit to both displays for a stable final value.

2

Stage 2: Pill Counting Per Bottle (Discrete Logic)

BCD Counters for Pills (74LS192)

Two cascaded 74LS192 BCD counters track pill count:

  • Units counter: Counts individual pills (0–9)
  • Tens counter: Increments when units rolls over from 9 to 0
  • Together they produce clean BCD counts from 00 to 99 without additional logic

Comparison with Target (SN74LS682)

An 8-bit magnitude comparator (SN74LS682) compares:

Input A

BCD value entered by the user

Input B

BCD value from the pill counters

When the values match, the comparator output changes state (active LOW). An inverter converts this to positive logic compatible with downstream modules.

End of Cycle Detection

When the comparator signals equality:

  • Both pill counters reset to zero
  • The system prepares for the next bottle
  • The equality signal is forwarded to the bottle counter

This ensures each bottle is counted exactly once with deterministic timing.

3

Stage 3: Counting Filled Bottles (Discrete Logic)

Modulo-8 Bottle Counter (74LS93)

A 74LS93 configured as a modulo-8 counter tracks filled bottles:

  • Uses only three bits (counting 0–7)
  • Each completed bottle increments the counter
  • Naturally wraps around after 7 (no extra detection logic needed)

Display of Bottle Count (74LS247)

The three-bit counter output drives a 74LS247 BCD-to-seven-segment decoder, which controls a dedicated seven-segment display showing the number of filled bottles (0–7). This provides real-time visual feedback on production progress.

Global Reset Using #

Pressing the # key resets:

  • Both pill counters
  • The bottle counter
  • The display system

This guarantees a clean return to a known and stable initial state for the next production cycle.

Why Arduino Was Chosen

Migrating the display and keypad logic to an Arduino provided significant engineering advantages over a purely discrete implementation:

Reduced Hardware Complexity

Eliminates dozens of debounce capacitors and logic gates

Elimination of Debounce Circuits

Release-detection algorithm handles bounce inherently

Improved Signal Stability

Software control ensures clean, predictable BCD outputs

Easier Future Modifications

Firmware changes require no PCB redesign

Better Synchronization

Precise timing control for Z and # signal pulses

TTL Compatibility

Direct BCD outputs work seamlessly with discrete logic

Project Resources & Media

ELE1001 circuit breadboard layout
Circuit breadboard layout (click to enlarge)
Project Presentation Video (YouTube)
🔗 GitHub Repository

Final Result

The complete system delivers a robust, production-ready solution for automated pill bottling:

  • Intuitive user input via matrix keypad
  • Stable, synchronized BCD output signals
  • Accurate pill counting from 0 to 99
  • Automatic bottle completion detection
  • Modular bottle tracking (0–7 bottles per box)
  • Clean, predictable state resets

The design respects digital logic principles, modularity, and real-world reliability constraints, demonstrating professional engineering practice in embedded systems.