There is at least one possability where a connected hardware can damage a microcontroller through a wrong sketch:
If a switch or a button is connected on one end to an IO-pin and the other end is connected to ground.
In combination with a sketch that does two additional things:
- configuring this IO-pin as OUTPUT
- setting this IO-pin HIGH
if the switch is closed then this would be a shortcut between 5V on the IO-pin beeing "HIGH" and ground. Then a too high current would flow from IO-pin to ground damaging minimum this IO-pin maybe more of the microcontroller.
Same if the button would be pressed to close the contact.
The same thing applies if the switch/button would be wired between IO-pin to +Vcc and then the sketch would
- configuring this IO-pin as OUTPUT
- setting this IO-pin LOW
This would be a shortcut between +Vcc and IO-pin making a too high current flow damaging the IO-pin.
This can be avoided by inserting a current-limiting resistor between IO-pin and whatever you connect to this IO-in
instead of directly IO-pin---------your-hardware
.
.
IO-Pin-----resistor-----your-hardware
In most cases the function of "your hardware" will be the same.
In most cases the influence of the current limiting resistor will be too small to ahve an result-changing effect.
In some cases this current-limiting resistor will have a result-changing effect.
This would be the case if the "your hardware" has an inpedance in the same range as the resistor.
For things like I2C-sensors, buttons, switches it will work.
You can ask in the forum for a specific hardware.
For some microcontrollers that have a software configurable clock, too high overclocking using very special configuration-functions might result in overheating the microcontroller.
The microcontroller-word is not super-standardised like USB-devices or bluetooth.
You have to take care of more details like
"does the plug fit into the socket?"
You should have a basic knowledge about voltage, current, resistance and Ohms law.
The arduino-forum has a sub-forum general electronics. So if you have a question which is mainly about electronics you could post this question there.