If you want your microcontroller to fit in tight spaces you need to use very small packages. One optin is to choose Atmel Attiny10 microcontroller which is really tiny. It has 6 pins, where 4 of them are I/O. It features 1KB of Flash, 32B of RAM and can be clocked at 12MHz. Power supply can vary between 1.8V to 5.5V. They come in two types of packages – SOT-23 and UDFN.
Dan Watson have built a mini breakout board for Attiny10 mincrocontroller. He wanted it to be really small and came out with size similar to 5mm LED head. To reduce size, he used small pitch (0.05”) header pins that doesn’t fit to breadboard. So additionally he made a special adapter board to be able to program it with standard ISP programmer.
Don be fooled by its size, it packs enough power to perform some great tasks. If you are willing to use assembly language, you can really squeeze out some serious juice of it.