How does a microcontroller "remember" a program?
The PIC includes a type of nonvolatile memory called &quot;Flash EEPROM&quot;. When you &quot;send your program to the microcontroller&quot;, the special adapter is in fact programming your code into this memory. The physical memory is a special kind of transistor with a floating gate that can store a charge more or less indefinitely, even with no power applied. In most devices, &quot;charged&quot; = 0, &quot;no charge&quot; = 1.
Whenever the PIC is reset or powered-up, it begins executing your code, fetching it directly from this memory.
On the PIC, this memory is integrated into the same chip that holds the CPU and the rest of the logic (peripherals, etc.). The same kind of memory is used to hold the BIOS in your desktop/laptop PC, but it's a separate chip from the CPU. The first few screens you see when you switch on your PC come from the BIOS, which then loads your operating system from hard drive or SSD and runs that.