In the last article, we introduce what is a microcontroller. Today, we continue to introduce how does a microcontroller work！
Microcontrollers are circuits that are microprocessor-based which have been developed to accomplish a particular task or a set of tasks. They are able to take information from outside and use the input to process data inside the circuit.
A microcontroller will always attempt to perform an action only when it is an "instruction". In the event that it's waiting until an outside event is about to happen, it will be constantly monitoring the hardware inputs that are used to identify the external event.
The microcontroller will stop the execution of the instruction and come to determine whether the event took place within the shortest time possible after it has detected that an external event. This makes it more energy-efficient than PCs. They don't have to be continuously powered on. Because different tasks can be completed by different microcontrollers or microprocessors while another one is waiting for input before carrying out another task. For instance, microcontrollers are made into toys to ensure that they are able to perform actions like making sounds and playing various phrases, without the need for buttons. The sounds and phrases will be saved within a read-only memory (ROM) while microcontrollers constantly monitor hardware inputs that are used to determine the moment when a button presses occurred.
The microcontroller will then respond to the signal of a button with a replay of one of the phrases or sounds stored in accordance with the button that is hit. It doesn't need to search for another input that requires action. It is only interested in the moment a button was pressed. It can save energy as compared to PCs that require continuous attention is required when multiple tasks are being performed simultaneously.
More relative information about the model of microcontrollers is here!