An interactive system based on low-power MCU and attitude sensor

By combining a low-power 8-bit MCU with an attitude sensor, intelligent mapping of motion and light effects on portable devices is achieved, solving the problems of high hardware cost and lack of physical mapping for interactive logic. This enhances the interactive fun and device battery life, and is suitable for various devices such as portable handhelds and ambient lights.

CN122308165APending Publication Date: 2026-06-30SHENZHEN LANGHENG ELECTRICAL

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN LANGHENG ELECTRICAL
Filing Date
2026-01-12
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing interactive systems for portable electronic devices suffer from high hardware costs, high power consumption, lack of physical mapping of interactive logic, and insufficient fun. In particular, it is difficult to achieve intelligent mapping of motion-feedback and smooth interaction on low-cost 8-bit MCU platforms.

Method used

It adopts a low-power 8-bit MCU combined with an attitude sensor, drives the LED array through a single bus protocol, and combines sensor interrupt wake-up and MCU sleep mechanism to design a multi-step control algorithm to realize intelligent mapping of action-physical logic-dynamic light effect, and supports fast switching between hourglass, dice rolling and constant light modes.

Benefits of technology

The system achieves a logical connection between dynamic lighting effects and user actions on a low-cost platform, enhancing the interactive fun and immersion, reducing hardware costs, adapting to the battery life requirements of portable devices, and supporting standardized intelligent interaction across multiple devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122308165A_ABST
    Figure CN122308165A_ABST
Patent Text Reader

Abstract

This invention provides an interactive system based on a low-power MCU and an attitude sensor, including a microcontroller unit, an attitude sensing unit, a dynamic display unit, and an interaction unit. The microcontroller unit generates and outputs control signals to the dynamic display unit in real time based on data from the attitude sensing unit and input from the interaction unit, presenting dynamic visual feedback related to the attitude action logic. This invention aims to solve the problems of disconnect between interaction and display, fixed user experience, high hardware costs, and insufficient performance on low-resource platforms in existing technologies. By optimizing the hardware architecture and innovating control algorithms, it achieves intelligent mapping of action, physical logic, and dynamic lighting effects on an 8-bit MCU platform, balancing cost-effectiveness and interactive experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent interaction technology, and in particular to an interaction system based on a low-power MCU and an attitude sensor. Background Technology

[0002] With the development of consumer electronics technology, intelligent interaction has become a core element in enhancing product competitiveness. From early single-button control to today's motion-sensing interaction and posture recognition, interaction methods are constantly evolving towards naturalness and intelligence. In the field of portable electronic devices, users' demands for interactive experiences have shifted from mere usability to fun and intelligence. The combination of posture sensors and LED display technology provides a foundation for achieving dynamic interaction. In early solutions, interaction and display functions were disconnected. Some products only switched fixed LED lighting effects via buttons, and the effects were mostly decorative flowing lights or breathing lights, lacking logical connection with user actions. Other products integrated accelerometers, but their functions were limited to simple controls such as power on / off and gear switching, failing to achieve deep binding between actions and displayed content. As demands have increased, the industry has begun to explore intelligent mapping of action-feedback, but existing solutions have obvious shortcomings. To achieve complex interactions, many use 32-bit high-performance MCUs and redundant sensors, resulting in high hardware costs and power consumption, making it difficult to meet the cost-sensitive needs of mass consumer electronics. On the low-cost 8-bit MCU platform, existing algorithms are inefficient and cannot simultaneously and smoothly process sensor data parsing, dynamic light effect control, and low-power management, resulting in sluggish interactions and poor user experience. In addition, the interaction logic of existing solutions lacks the characteristics of physical mapping. For example, the shaking action only mechanically switches the light effects and cannot simulate the random logic of rolling dice. The hourglass light effect has a fixed flow direction and cannot correspond to the physical cause and effect of the inverted action, resulting in a rigid interactive experience and insufficient fun. These problems limit the intelligent interaction upgrade of low-power portable electronic devices. Therefore, there is an urgent need in this field for an interactive system that balances low cost, low power consumption, and high interactivity. Summary of the Invention

[0003] This invention provides an interactive system based on a low-power MCU and a posture sensor, aiming to solve the problems of disconnect between interaction and display, rigid experience, high hardware cost and insufficient performance of low-resource platforms in the prior art. By optimizing the hardware architecture and innovating the control algorithm, it realizes intelligent mapping of action-physical logic-dynamic light effects on an 8-bit MCU platform, balancing cost-effectiveness and interactive experience.

[0004] This invention provides an interaction system based on a low-power MCU and an attitude sensor, comprising: The microcontroller unit is used to perform system control and data processing; An attitude sensing unit, which is connected to the microcontroller unit, is used to detect changes in the attitude and motion of the device and output corresponding sensing data. A dynamic display unit, which is connected to the microcontroller unit, is used to present dynamic light effects according to control commands; An interaction unit, which is connected to the microcontroller unit, is used to receive user input to trigger mode switching or function control; The microcontroller unit generates and outputs control signals to the dynamic display unit in real time based on the data from the posture sensing unit and the input from the interaction unit, so as to present dynamic visual feedback related to the posture and action logic.

[0005] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: 1. This invention establishes a physical logical connection between actions such as shaking and inversion and light effects feedback such as hourglass reversal and dice roll generation through the collaboration of the posture sensing unit and the dynamic display unit, replacing the traditional mechanical switching mode and enhancing the interactive fun and immersion.

[0006] 2. This invention uses an 8-bit low-power MCU paired with a simplified attitude sensor, and drives the LED array through a single bus protocol, occupying only a single GPIO pin, thus reducing hardware resource consumption; combined with sensor interrupt wake-up and MCU sleep mechanism, it achieves low-power operation of the system, adapts to the battery life requirements of portable devices, and reduces hardware costs to meet the positioning of the mass consumer market.

[0007] 3. This invention designs a multi-step control algorithm that integrates data filtering, action recognition, random point generation, and color dynamic mapping logic. The algorithm is concise and efficient, and can run smoothly on an 8-bit MCU with limited memory and computing resources, solving the problem of interaction lag on low-resource platforms.

[0008] 4. This invention supports quick switching between three modes: hourglass, dice, and constant light. The speed of the hourglass light particles, the color sequence, and the rules for generating dice points can all be customized to suit different user habits. The shaking intensity and direction are mapped to differentiated RGB colors, enhancing the randomness and personalization of the interaction.

[0009] 5. The system architecture of this invention does not depend on a specific hardware form and can be flexibly applied to various devices such as portable flashlights, ambient lights, and portable toys, providing a standardized intelligent interaction solution for various low-power portable electronic devices, and has strong promotional value.

[0010] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0011] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention, but do not constitute a limitation thereof; in the drawings: Figure 1 This is a schematic diagram of the structure of an interactive system based on a low-power MCU and an attitude sensor provided by the present invention. Detailed Implementation

[0012] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention. Example 1:

[0013] This invention provides an interaction system based on a low-power MCU and an attitude sensor. Please refer to [link / reference]. Figure 1 ,include: The microcontroller unit is used to perform system control and data processing; The attitude sensing unit, which is connected to the microcontroller unit, is used to detect changes in the attitude and motion of the device and output corresponding sensing data. A dynamic display unit, which is connected to a microcontroller unit, is used to present dynamic light effects according to control commands; An interaction unit, which is connected to a microcontroller unit, is used to receive user input to trigger mode switching or function control; The microcontroller unit generates and outputs control signals to the dynamic display unit in real time based on the data from the attitude perception unit and the input from the interaction unit, so as to present dynamic visual feedback related to the attitude action logic.

[0014] Specifically, the system in this embodiment constructs an interactive link of perception-processing-input-output through the collaborative work of four units. The posture perception unit captures the device's posture changes (such as tilting or inversion) and motion actions (such as shaking) in real time and converts them into sensing data in the form of electrical signals. The interaction unit receives user-initiated operation commands (such as button triggering). The microcontroller unit, as the core hub, performs comprehensive analysis and processing on the two types of input signals to generate appropriate control signals. The dynamic display unit responds to the control signals and presents corresponding dynamic light effects. Moreover, the dynamic light effects are physically and logically related to the posture actions (such as the inversion action corresponding to the reversal of the light effect flow direction), thus realizing an intelligent interactive experience.

[0015] In one implementation, the microcontroller unit is an 8-bit low-power microcontroller with limited built-in memory and storage resources. It supports interrupt response and GPIO control, and is used to run preset control algorithms to realize the parsing of sensor data, display logic control, and low-power management.

[0016] Specifically, the microcontroller unit in this embodiment uses a low-power 8-bit architecture. Although its memory (RAM) and program storage space (Flash) are limited by hardware specifications, they can meet the requirements of the core system functions. It has interrupt response capability and can quickly respond to external trigger signals (such as the interrupt wake-up signal of the attitude sensing unit). It realizes signal interaction with other units through GPIO (General Purpose Input / Output) pins. The unit pre-stores control algorithm programs. When running, it can perform parsing operations such as format conversion, outlier handling, and feature extraction on the sensing data transmitted by the attitude sensing unit. Based on the parsing results, it generates control instructions that conform to the display logic. At the same time, it has low-power management function and can switch to sleep mode when the system is not in operation to reduce overall power consumption. In one implementation, the attitude sensing unit includes a triaxial accelerometer with built-in programmable interrupt functionality and a low-power mode, which wakes up the microcontroller unit via an interrupt pin when a specific action or attitude change is detected.

[0017] Specifically, the core component of the attitude sensing unit in this embodiment is a triaxial accelerometer. This accelerometer can simultaneously collect acceleration data of the device in the three orthogonal coordinate axes of X, Y, and Z, thereby realizing the detection of attitude changes (such as tilting or inversion) and motion actions (such as swaying). Its built-in programmable interrupt function supports users to preset interrupt trigger conditions (such as the rate of change of acceleration exceeding a threshold or the tilt angle reaching a set value). The low-power mode can reduce its own power consumption when there is no trigger event. When a specific action or attitude change that meets the preset conditions is detected, the accelerometer outputs an interrupt signal through a dedicated interrupt pin, triggering the microcontroller unit in the sleep state to wake up and enter the working state, ensuring the system's timely response while reducing power consumption.

[0018] In one implementation, the dynamic display unit includes a ring or array structure composed of several independently addressable RGB LEDs, which is connected to the microcontroller unit via a single bus protocol and occupies one GPIO pin.

[0019] Specifically, in this embodiment, the display body of the dynamic display unit consists of multiple RGB LED beads. The beads are arranged in a ring or array to achieve omnidirectional or specific area light effect display. Each RGB LED bead supports independent addressing, meaning that the microcontroller unit can control the on / off state, brightness, and color of a single bead individually. This unit communicates with the microcontroller unit using a single-bus protocol. It only needs to occupy one GPIO pin of the microcontroller unit to realize the transmission of control signals for all LED beads, without occupying more IO resources. By receiving the control signals from the microcontroller unit, it presents various dynamic light effects such as light particle flow, dot matrix display, color gradient, and constant light.

[0020] In one embodiment, the interaction unit includes at least one physical button for performing at least one of the following operations: power on, power off, mode switching, and function selection.

[0021] Specifically, in this embodiment, the hardware form of the interactive unit is one or more physical buttons. The buttons are connected to the microcontroller unit through a circuit. When the user presses the button, a level change signal is generated and transmitted to the microcontroller unit. The unit identifies the button function according to a preset mapping relationship. The operations that the buttons can perform include, but are not limited to: double-clicking a specific button to trigger the system to power on or off, single-clicking the corresponding button to trigger the switching of working modes (such as switching from hourglass mode to dice mode), and long-pressing the button to select functions (such as customizing the light effect color or adjusting the flow speed of light particles), providing the user with an intuitive active operation interface.

[0022] In one implementation, the interactive system supports an hourglass mode, in which the microcontroller unit controls the dynamic display unit to simulate the flow of light particles along a set path, and automatically reverses the flow direction based on the tilt angle detected by the attitude sensing unit.

[0023] Specifically, in this embodiment, the preset hourglass mode is one of the core working modes. When the system enters this mode, the microcontroller unit outputs control signals to the dynamic display unit, controlling multiple RGB LED beads to light up and turn off in a preset order, simulating the visual effect of "light particles" flowing along a set path (such as one side of a ring structure from top to bottom). After a single light particle reaches its end point, it triggers the next light particle to start flowing, until a complete cycle is completed. At the same time, the attitude sensing unit detects the tilt angle of the device in real time and transmits the data to the microcontroller unit. When the detected tilt angle exceeds the preset angle threshold (i.e., it is determined to be an inverted action), the microcontroller unit immediately adjusts the control signal to reverse the flow direction of the light particles in the dynamic display unit (such as from bottom to top), intuitively presenting the physical logic of the change in the flow direction of the sand particles after the hourglass is inverted.

[0024] In one implementation, the interactive system supports a dice-shaking mode, in which the microcontroller unit generates random numbers based on the shaking motion data collected by the attitude sensing unit, and displays the corresponding numbers in a dot matrix on the dynamic display unit, with the display color dynamically changing with the shaking characteristics.

[0025] Specifically, this embodiment provides a dice-shaking mode. When the system enters this mode, the attitude sensing unit collects the shaking motion data of the device in real time (mainly X, Y, and Z axis acceleration data) and transmits it to the microcontroller unit. The microcontroller unit extracts features from the shaking data (such as shaking force, duration, and direction) and generates a random number in the range of 1 to 6 based on a preset algorithm. The dynamic display unit lights up the corresponding number of RGB LED beads according to the dot matrix display rules to display the dice roll corresponding to the random number (e.g., if the random number is 3, then 3 LED beads are lit to form a dot matrix). At the same time, the display color is related to the shaking features. When the shaking force and direction are different, the brightness combination of the RGB three primary colors of the LED beads changes, making the color displayed for each roll different and enhancing the interactive fun.

[0026] In one embodiment, the interactive system is characterized by supporting at least three switchable working modes, including hourglass mode, dice rolling mode, and always-on mode, and the sequential switching between modes is achieved through the interactive unit.

[0027] Specifically, the system operating modes in this embodiment include hourglass mode (light particle flow simulates the hourglass effect), dice rolling mode (shaking generates random numbers and displays them), and constant-on mode (the dynamic display unit maintains constant brightness and color). It also supports cyclic switching between the three modes. The switching operation is triggered by the interaction unit. The preset switching logic is as follows: clicking the first button of the interaction unit executes "function forward switching" (e.g., hourglass mode → dice rolling mode → constant-on mode → hourglass mode), and clicking the second button executes "function backward switching" (e.g., hourglass mode → constant-on mode → dice rolling mode → hourglass mode). Users can quickly switch to the target operating mode by pressing the buttons according to their needs.

[0028] In one implementation, the microcontroller unit enters a low-power sleep state when there is no operation, and is woken up by an interrupt signal from the attitude sensing unit, thereby achieving low-power operation of the entire system.

[0029] Specifically, the microcontroller unit in this embodiment has built-in low-power management logic. When it detects that the system has no operation (including no attitude change or no key input) for a period of time that reaches a preset threshold, it automatically switches to a low-power sleep state. At this time, the microcontroller unit only maintains the minimum power consumption of the core circuit, and other non-essential circuits stop working. When the attitude sensing unit detects a specific action or attitude change, it outputs an interrupt signal through the interrupt pin. This signal can directly wake up the microcontroller unit, allowing it to quickly return to normal working state and respond to external triggers. Through the dynamic switching mechanism of sleep-wake, the overall power consumption of the system is reduced to the maximum extent and the battery life is extended while ensuring the normal implementation of system functions.

[0030] In one implementation, the microcontroller unit executes a preset control algorithm to generate display control signals based on attitude data: Obtain the three-axis instantaneous acceleration values ​​output by the accelerometer. ; Calculate acceleration amplitude ; Calculate the rate of change of acceleration And it is smoothed by low-pass filtering; Determine the action type based on a preset threshold: If the rate of change of acceleration Greater than the set acceleration change rate threshold And duration If the action is incorrect, it is considered a shaking motion and the game enters dice-shaking mode. If the tilt angle Exceeding the set angle threshold If so, it is determined to be an inverted action, triggering the reversal of the hourglass flow direction; In dice rolling mode, the random number of points... Generated by the following formula:

[0031] in, For the first sampling window Each acceleration amplitude, For the corresponding timestamp, For the preset angular frequency, To prevent division by zero of small constants; Display color Based on dynamic mapping of shaking intensity and direction: ; in This represents the average acceleration of each axis within the action time window. This is the preset maximum acceleration reference value; The microcontroller unit outputs control signals, including display mode, number of dots, color, and direction of light particle flow, to the dynamic display unit according to the preset control algorithm.

[0032] Specifically, the preset control algorithm in this embodiment is the core logic for the microcontroller unit to generate display control signals, and it is implemented in the following steps: (1) Data acquisition: The microcontroller unit reads the real-time data output by the three-axis accelerometer in the attitude sensing unit through the communication interface, that is, the instantaneous acceleration value of the X-axis. Instantaneous acceleration value along the Y-axis Z-axis instantaneous acceleration value The data unit is m / s 2 This reflects the intensity of the device's motion in the corresponding coordinate axis direction; (2) Acceleration amplitude calculation: Based on the Euclidean space vector magnitude calculation formula, the instantaneous acceleration values ​​of the three axes are synthesized to obtain the acceleration amplitude. This value comprehensively reflects the overall motion intensity of the device at the current moment; (3) Calculation and smoothing of the rate of change of acceleration: The acceleration amplitude is calculated by numerical differentiation method. rate of change over time (Unit: m / s) 3 Since the original rate of change data may contain noise, a low-pass filtering algorithm (such as a first-order RC low-pass filter) is used to smooth it, remove high-frequency noise interference, and obtain a stable rate of change signal. (4) Action type judgment: Four key threshold parameters are preset, namely the acceleration change rate threshold. Minimum duration of shaking motion Maximum duration of shaking motion Tilt angle threshold The threshold parameter can be preset by the program according to the actual application scenario; when the condition is met... And the duration of the action is When the action falls within the specified range, it is considered a shaking motion, and the system triggers dice-shaking mode; the tilt angle is calculated using the arctangent function. This angle is based on the horizontal state of the device and reflects the angle between the device on the Y-axis and the horizontal plane. When this is detected as an inverted action, the system triggers the reversal of the light particle flow direction in hourglass mode; (5) Random number generation in dice rolling mode: ,in, The number of sampling points within the sampling window is determined by the sampling frequency of the microcontroller unit and the duration of the shaking motion (e.g., if the sampling frequency is 100Hz and the shaking lasts for 0.5 seconds). =50); The acceleration amplitude corresponding to the kth sampling point within the sampling window is calculated using the method in step (2); The timestamp of the kth sampling point is recorded synchronously by the system clock of the microcontroller unit; The preset angular frequency has a range of 2π~10πrad / s (corresponding to 1Hz~5Hz) to match the natural frequency of human hand shaking; To prevent division by zero, the value range of small constants is 10. -6 ~10 -3 This is much smaller than the total actual acceleration of the shaking, and does not affect the accuracy of the calculation; In the formula, the numerator To achieve the fusion of shaking force and timing characteristics, The periodicity of the swaying motion is simulated, causing the force weight at different points in time to change over time, thus avoiding uneven distribution of points caused by a single force value; denominator Add a division-by-zero constant to the sum of all acceleration amplitudes within the sampling window to normalize the molecular data, ensuring the fractional part ranges from -1 to 1; multiply the normalized result by 6 and round down. (), to obtain integers from 0 to 5, through "1+" offset and modulo operation. The final mapping is a random number between 1 and 6; (6) Color mapping displayed in dice rolling mode: The formula is ;in, These are the average values ​​of the X, Y, and Z axis accelerations within the time window of the shaking motion. They are obtained by summing the acceleration data of each axis within the sampling window and dividing by the number of sampling points, m. The maximum acceleration reference value is preset and is set to the maximum measured value of the triaxial accelerometer to ensure that the average acceleration of all actual measurements does not exceed this reference. In this formula, The average acceleration values ​​of each axis are normalized to the range of 0 to 1, and then multiplied by 255 to obtain a numerical range of 0 to 255. This range conforms to the brightness value requirements in the RGB color standard. The values ​​are then rounded down. The brightness is converted into integer values, corresponding to the luminous intensity of the three channels: R (red), G (green), and B (blue). The average acceleration distribution of different axes corresponds to different color combinations, realizing dynamic control of the displayed color by shaking intensity and direction, enhancing the interactive fun. (7) Control signal output: Based on the calculation results of the above algorithm, the microcontroller unit integrates information such as display mode (e.g., dice rolling mode, hourglass mode), dice roll number (N), display color (R, G, B), and light particle flow direction to generate standardized control signals, which are transmitted to the dynamic display unit through the communication interface to drive it to present the corresponding dynamic light effect. Example

[0033] This invention provides a portable flashlight for an hourglass and dice, which utilizes an interaction system based on a low-power MCU and an attitude sensor from Embodiment 1. The portable flashlight includes a housing, a core control component housed within the housing, a dynamic display component located on the side of the housing, an interactive button component located on the surface of the housing, and a power supply component for each component. The specific structure, connection relationships, and functional implementation of each component are as follows: The core control components are the microcontroller unit and attitude sensing unit in Example 1, which are the control core of the portable flashlight and realize data processing, action recognition and command generation functions.

[0034] The microcontroller module uses a CMS8S6990 8-bit low-power microcontroller with limited built-in RAM and Flash program storage. It features interrupt response capabilities and multiple general-purpose I / O ports, establishing signal connections with the dynamic display and interactive button components via these ports. Data interaction with the attitude sensing module is achieved through the I2C communication protocol. This microcontroller module is pre-programmed with preset control algorithms, enabling it to parse and process sensor data transmitted from the attitude sensing module, identify operation signals transmitted from the interactive button components, and generate corresponding display control commands. It also possesses low-power management capabilities, entering a sleep state when not in use to reduce system power consumption.

[0035] The attitude sensing module uses a LIS3DH triaxial accelerometer, which is connected to the microcontroller module via an I2C communication bus and also connected to the microcontroller module's interrupt interface via an interrupt pin. This triaxial accelerometer can collect instantaneous acceleration data of the portable flashlight in the X, Y, and Z axes in real time, used to detect changes in the flashlight's attitude (such as inversion or tilting) and movements (such as shaking). It has a built-in programmable interrupt function, allowing preset interrupt trigger conditions (such as the rate of change of acceleration exceeding a set threshold or the tilt angle reaching a threshold). It also supports a low-power mode, reducing its own power consumption when there are no trigger events. When a movement or attitude change that meets the conditions is detected, a signal is output through the interrupt pin to wake up the dormant microcontroller module, ensuring timely response while reducing overall power consumption.

[0036] The dynamic display component, as described in Example 1, is a dynamic display unit used to receive control commands and present dynamic lighting effects. Specifically, it consists of a ring array of 18 WS2812B intelligent RGB LED beads embedded in a ring mounting groove on the side of the portable battery housing. Nine evenly distributed light-transmitting holes (light-transmitting holes 1-9) are set on the outer side of the LED beads corresponding to the housing position. The light emitted by the LED beads can be projected outward through the light-transmitting holes to form an intuitive visual effect. This ring LED array is connected to a single GPIO pin of the microcontroller module via a single bus protocol. Independent control of all LED beads can be achieved by occupying only a single IO resource. The control signal output by the microcontroller module can precisely adjust the on / off state, brightness, and color of each LED bead, thereby simulating various dynamic lighting effects such as light particle flow, dot matrix display, and constant light, adapting to the display requirements of three working modes: hourglass, dice rolling, and constant light.

[0037] The interactive button component is the interactive unit in Embodiment 1, used to receive user operation input. Specifically, it includes three physical buttons, namely Set button, button 1, and button 2, all of which are embedded in the button area on the top of the portable flashlight housing. They are connected to the microcontroller module through a circuit. When pressed, they generate a level change signal and transmit it to the microcontroller module to realize the corresponding function control. Set button: Supports double-click operation. Double-clicking triggers the on / off function of the portable flashlight side light. After powering on, it enters hourglass mode by default. Button 1: Supports single-click operation. In any mode where the side light is on, clicking will perform "Function Forward Switch". The switching order is hourglass mode → dice mode → constant light mode → hourglass mode. Button 2: Supports single-click operation. In any of the side light illumination modes, single-clicking will perform "function reversal". The switching order is hourglass mode → constant light mode → dice mode → hourglass mode.

[0038] The power supply components provide a stable power supply for all components of the portable flashlight, including the rechargeable lithium battery, voltage regulator, filter, and power management unit. A rechargeable lithium battery serves as the power source, providing a 3.7V DC voltage; The voltage regulator unit uses a low dropout linear regulator. The input terminal is connected to the lithium battery, and the output terminal outputs a stable 3.3V voltage to meet the operating voltage requirements of each component. The filter unit adopts a parallel capacitor structure, with one end connected to the output of the voltage regulator unit and the other end grounded, to filter out ripple noise in the voltage and ensure power supply stability. The power management unit is connected to the microcontroller module, attitude sensing module, dynamic display component and interactive button component respectively. It is controlled by the microcontroller module and switches the power supply mode according to the system working state. When the system is in sleep mode, the power supply power is reduced to further optimize the low power performance.

[0039] During the process of implementing hourglass mode, after double-clicking the Set button to power on, the system automatically enters hourglass mode. The microcontroller module outputs control signals to the dynamic display component to activate the hourglass light effect logic. The first "light particle" is composed of a single high-brightness RGB LED. Starting from the LED corresponding to the light-transmitting hole 1, it lights up and turns off sequentially along the path of light-transmitting hole 1→2→3→…→9, simulating the light particle flowing from top to bottom. When the first light particle reaches the position of the lamp bead corresponding to the light-transmitting hole 9, it triggers the second light particle to flow from the light-transmitting hole 1, and so on, until the ninth light particle completes its flow, and one side of the ring LED array is fully lit, completing one hourglass cycle. After one cycle, the microcontroller module automatically switches the color of the light particles (the preset color sequence is red→pink→purple→orange→green→blue, which can be modified by the program) and restarts the flow of light particles to achieve the color cycle change; During hourglass mode operation, the attitude sensing module collects the flashlight's three-axis acceleration data in real time, and the microcontroller module calculates the tilt angle using an algorithm. ,when Exceeding the set angle threshold When the angle is 90° (preset), the flashlight is determined to be inverted. The microcontroller module adjusts the control signal in real time to change the color of the light particles and reverse the flow direction (flowing along the path of light-transmitting holes 9→8→…→1), visually presenting the physical effect of sand particles flowing in reverse after the hourglass is inverted. In addition, the program parameters can be modified to customize the light particle flow speed (the interval between the movement of a single light particle) and the length of a single cycle (e.g., a complete cycle corresponds to 30 seconds, thus realizing the timing function), to adapt to different user needs.

[0040] During the dice-shaking mode, after switching to dice-shaking mode by clicking button 1 or button 2, the system enters the dice-shaking waiting state; When the user shakes the flashlight, the attitude sensing module collects the instantaneous acceleration values ​​of the X, Y, and Z axes in real time. And transmit it to the microcontroller module via the I2C protocol; The microcontroller module executes a preset control algorithm: calculating the acceleration amplitude. Calculate the rate of change of acceleration And after low-pass filtering and smoothing, when the following conditions are met... And duration (Preset) =0.3 seconds If the shaking action lasts for 3 seconds, it is considered a valid shaking action. Based on the collected data of effective shaking motions, a formula is generated using random point counts. Generate random numbers between 1 and 6, where The preset value is 4πrad / s (corresponding to 2Hz, matching the natural frequency of human body shaking). =10 −5 ; At the same time, display colors are generated using color mapping formulas. , , ,in The preset speed is 156.8 m / s 2 (Corresponding to the maximum measurement value of the LIS3DH accelerometer); The microcontroller module outputs control signals to the dynamic display component, controlling the ring LED array to light up the corresponding number of LED beads in a dot matrix pattern (e.g., if the number of dots is 3, then 3 LED beads will be lit), and emit light according to the calculated color; if the user shakes the flashlight and keeps it still for ≥2 seconds, the system locks the current number of dots and color display to avoid multiple judgments and ensure that the result is stable and readable.

[0041] During the process of achieving constant-on mode, after switching to constant-on mode by clicking button 1 or button 2, the microcontroller module outputs a control signal to control the ring LED array of the dynamic display component to maintain constant brightness and color, forming an ambient lighting effect. The brightness and initial color can be preset by the program to meet the needs of daily lighting or atmosphere creation.

[0042] When the portable flashlight is not operated (no button input, no posture change) for a duration that reaches a preset threshold (preset to 30 seconds), the microcontroller module controls the system to enter a low-power sleep state. At this time, the microcontroller module and dynamic display components reduce power consumption, and only the posture sensing module maintains a low-power monitoring state. When the user presses any button or shakes the flashlight, the posture sensing module detects the action and outputs an interrupt signal, waking up the microcontroller module and other components, restoring normal working state, and achieving low-power battery life.

[0043] The portable flashlight in this embodiment uses the interactive system of embodiment 1 to achieve intelligent and highly interactive dynamic light effect function on a low-cost 8-bit MCU platform. It solves the problems of functional fragmentation, solidified experience and high cost in the prior art. At the same time, it has the advantages of easy operation, low power consumption and high fun, and is suitable for mass consumer electronics scenarios.

[0044] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An interaction system based on a low-power MCU and an attitude sensor, characterized in that, include: The microcontroller unit is used to perform system control and data processing; An attitude sensing unit, which is connected to the microcontroller unit, is used to detect changes in the attitude and motion of the device and output corresponding sensing data. A dynamic display unit, which is connected to the microcontroller unit, is used to present dynamic light effects according to control commands; An interaction unit, which is connected to the microcontroller unit, is used to receive user input to trigger mode switching or function control; The microcontroller unit generates and outputs control signals to the dynamic display unit in real time based on the data from the posture sensing unit and the input from the interaction unit, so as to present dynamic visual feedback related to the posture and action logic.

2. The interactive system according to claim 1, characterized in that, The microcontroller unit is an 8-bit low-power microcontroller with limited built-in memory and storage resources. It supports interrupt response and GPIO control, and is used to run preset control algorithms to realize the parsing of sensor data, display logic control, and low-power management.

3. The interactive system according to claim 2, characterized in that, The attitude sensing unit includes a three-axis accelerometer with built-in programmable interrupt function and low-power mode. When a specific action or attitude change is detected, the microcontroller unit is woken up via an interrupt pin.

4. The interactive system according to claim 1, characterized in that, The dynamic display unit includes a ring or array structure composed of several independently addressable RGB LEDs, which is connected to the microcontroller unit via a single bus protocol and occupies one GPIO pin.

5. The interactive system according to claim 1, characterized in that, The interactive unit includes at least one physical button for performing at least one of the following operations: power on, power off, mode switching, and function selection.

6. The interactive system according to claim 3, characterized in that, The interactive system supports an hourglass mode, in which the microcontroller unit controls the dynamic display unit to simulate the flow of light particles along a set path, and automatically reverses the flow direction according to the tilt angle detected by the attitude sensing unit.

7. The interactive system according to claim 6, characterized in that, The interactive system supports a dice-shaking mode. In this mode, the microcontroller unit generates random numbers based on the shaking motion data collected by the posture sensing unit, and displays the corresponding numbers in a dot matrix on the dynamic display unit. The display color changes dynamically with the shaking characteristics.

8. The interactive system according to claim 1, characterized in that, The interactive system supports at least three switchable working modes, including hourglass mode, dice rolling mode, and always-on mode, and the sequential switching between modes is achieved through the interactive unit.

9. The interactive system according to claim 2, characterized in that, When the microcontroller unit is not in operation, it enters a low-power sleep state and is woken up by the interrupt signal of the attitude sensing unit, so as to realize the overall low-power operation of the system.

10. The interactive system according to claim 6, characterized in that, The microcontroller unit executes the following preset control algorithm to generate display control signals based on the attitude data: Obtain the triaxial instantaneous acceleration values ​​output by the accelerometer. ; Calculate acceleration amplitude ; Calculate the rate of change of acceleration And it is smoothed by low-pass filtering; Determine the action type based on a preset threshold: If the rate of change of acceleration Greater than the set acceleration change rate threshold And duration If the action is incorrect, it is considered a shaking motion and the game enters dice-shaking mode. If the tilt angle Exceeding the set angle threshold If so, it is determined to be an inverted action, triggering the reversal of the hourglass flow direction; In dice rolling mode, the random number of points... Generated by the following formula: ; in, For the first sampling window Each acceleration amplitude, For the corresponding timestamp, For the preset angular frequency, To prevent division by zero of small constants; Display color Based on dynamic mapping of shaking intensity and direction: ; in This represents the average acceleration of each axis within the action time window. This is the preset maximum acceleration reference value; The microcontroller unit outputs control signals, including display mode, number of dots, color, and light particle flow direction, to the dynamic display unit according to the above-mentioned preset control algorithm.