A Ticket Selling Machine system that simulates a ticket vending experience using a thermal printer, an LED matrix display, audio playback (DFPlayer Mini), and physical buttons. The system is split into two logic units that communicate via GPIO.
The project consists of two independent subsystems:
-
Main Control Unit (
main_control/)- Platform: MicroPython (ESP32).
- Responsibilities:
- Handling user input from physical buttons.
- Controlling the Thermal Printer via UART (TTL).
- Controlling audio playback via DFPlayer Mini.
- Sending control signals to the LED Screen unit.
- Key File:
main_control/New_Main.py
-
LED Screen Display Unit (
ledscreen/)- Platform: Arduino C++ (ESP32).
- Hardware: HUB75 RGB LED Matrix.
- Responsibilities:
- Rendering the user interface (UI).
- Displaying station lists, ticket information, and animations.
- Communicating state changes back to the Main Control unit.
- Key File:
ledscreen/New_LED.ino
The two units communicate using a simple 4-wire GPIO protocol.
| Main Control (Pin) | Direction | LED Screen (Pin) | Function |
|---|---|---|---|
12 (LED_TO_PIN_1) |
-> |
35 (LED_IN_PIN_2) |
Signal "Next" / Change selection |
13 (LED_TO_PIN_2) |
-> |
34 (LED_IN_PIN_1) |
Signal "Confirm" / Select |
21 (LED_FROM_PIN_1) |
<- |
21 (LED_OUT_PIN_1) |
Feedback: Selection changed (Pass) |
22 (LED_FROM_PIN_2) |
<- |
22 (LED_OUT_PIN_2) |
Feedback: Selection confirmed |
Note: Pin assignments are based on
New_Main.pyandNew_LED.ino. Always verify physical wiring.
- Thermal Printer:
- TX: Pin 16
- RX: Pin 17
- Baud Rate: 115200
- DFPlayer Mini:
- TX: Pin 26
- RX: Pin 27
- Buttons:
- Button 1 (Next): Pin 4 (Pull-down)
- Button 2 (Confirm): Pin 5 (Pull-down)
- Standard HUB75 pinout (R1, G1, B1, R2, G2, B2, A, B, C, D, E, CLK, LAT, OE) defined in
New_LED.ino.
-
main_control/: MicroPython source code.New_Main.py: Entry point for the main controller. Contains the state machine for button presses, printer commands (print_text), and audio triggers.dfplayermini.py: Driver library for the MP3 module..mpyproject.json: Configuration for Pymakr/MicroPython tools.
-
ledscreen/: Arduino/C++ source code.New_LED.ino: Main Arduino sketch. Handles the display state machine (INIT,CHECK,PICK), drawing logic (draw_ticket_interface), and randomization.Data.h: Bitmap data for fonts and images (e.g.,station_list_matrixData).ESP32-HUB75-VirtualMatrixPanel_T.hpp: Driver/wrapper for the LED matrix.
- Environment: VS Code with Pymakr extension or similar MicroPython tools.
- Upload
New_Main.pyanddfplayermini.pyto the board. New_Main.pyruns in awhile Trueloop and will run automatically on boot if renamed tomain.pyor called from it.
- Environment: Arduino IDE or PlatformIO.
- Dependencies:
ESP32-HUB75-MatrixPanel-I2S-DMAlibrary.Adafruit GFX(required by the matrix library).
- Compile and upload
New_LED.inoto the ESP32 driving the matrix.
- Printer Commands:
New_Main.pycontains a comprehensive set of byte sequences for controlling the thermal printer (formatting, Chinese characters, barcodes). Do not modify the byte constants unless you know the specific ESC/POS commands. - Randomization: The "Pick" feature (ticket lottery) uses a random seed to simulate a spinning roulette before settling on a station.
MIT License. See LICENSE.