Operating Voltage
Microcontroller boards need a supply voltage to power them on, usually between 5V and 12V. They have output voltage pins to supply power to connected components, which can be 5V or 3.3V or both. The operating voltage of a board is the voltage of the signal output on the pins to which components and other boards are connected to exchange data with, which can be 5V or 3.3V (but not both).
Modules and components almost always have the same supply and operating voltage.
It is very important to know the operating voltage of the board and each connected component. If a component with a 3.3V operating voltage is connected to a board with a 5V operating voltage the component may burn out. If a component with a 5V operating voltage is connected to a board with a 3.3V operating voltage it may not work properly.
For example, an Arduino Nano can supply 5V or 3.3V to power components but has an operating voltage of 5V. So even if you connect a 3.3V component with the correct supply voltage it may still burn out because the signals from the Nano will be at 5V.
On the other hand an ESP32 can only supply 3.3V and has the same operating voltage. So all 3.3V components will work just fine but 5V components may need an alternative power supply, while the signal voltage may be sufficient.
If you must use a board and components with different operating voltages, you can use a level shifter. This is a circuit used to translate signals from one voltage level to another. Level shifters only work with digital signals, you cannot level shift analog signals. For some 3.3V components, the pins are 5V tolerant so a level shifter is not required.
Powering Modules and Components
When starting with building circuits we typically use breadboards. Modules and components are then supplied power directly from the output power pins on the board. You can get a breadboard compatible power supply module with a barrel jack connector that can be used to power modules and components separately using an AC to DC converter.
Current Drawn
Each microcontroller board is capable of supplying a maximum current and each connected component draws a certain amount of current. If the connected components together draw more current that the microcontroller board can supply the circuit may not work properly.
Common Ground
All power supplies, boards, and components that are connected to each other must have a common ground. While boards and connected components generally always have the same ground, mutliple boards exchanging data with each other may not always share a ground. This is especially important if two boards are exchaging data using UART or if a microcontroller and the connected components are powered by different sources.
Disconnected Pins
It is natural to assume that a pin that is not connected to anything is at 0V. In reality, a disconnected pin (also referred to as a floating pin) has an undefined state, as in it may actually have a voltage sufficient to indicate a HIGH signal or it may even randomly switch between having and not having any voltage. This is due to the electrical noise it can pick up from the electrical system in your house or other electric field sources.
This problem is notable when using a switch. If the switch is in the off position, the pin providing the voltage from the switch is expected to be at 0V and therefore provide a LOW signal, indicating that the switch is in the off position. With the possibility of a floating pin having a random voltage, it may continue to send a HIGH signal indicating that the switch is on when it is intended to be off.
Pull-up Resistors
While this concept is explained for your understanding, it is advisable not to actually use physical pull-up or pull-down resistors in your circuit. If the resistor values or connections are incorrect it could damage your microcontroller board or components.
Most microcontroller boards have what is known as an internal pull-up resistor that can be activated for a pin if required using code. Note that there is no INPUT_PULLLDOWN option since that is not recommended.
pinMode(3, INPUT_PULLUP)
To resolve this problem of the unknown state of a floating pin, you can use what is referred to as a pull-up resistor. In this approach, as shown in the illustration below, the input pin (pin 3) is connected to the VCC of the power supply through a resistor. This results in a proper voltage and current (and a HIGH signal) on the pin when the switch is off. When the switch is turned on, it connects the input pin directly to ground. The current now flows through the resistor to ground, and the input pin is grounded and has a clear 0V (and a LOW signal).
In this approach the resistor is very important as without it the button would connect VCC to ground, which is referred to as a short circuit and is very dangerous.
The reverse of a pull-up resistor would be a pull-down resistor. In this approach, as shown in the illustration below, the input pin is connected to the ground of the power supply through a resistor. When the switch is off, it connects the input pin directly to ground and has a clear 0V (and a LOW signal). When the switch is turned on a proper voltage and current (and a HIGH signal) is available on the pin.
Although the pull-up resistor approach is counter-intuitive, since you would normally expect a LOW signal when the button is off, it is more commonly used than the pull-down resistor. The microcontroller program should be coded accordingly.