I'm very new to electronics as a whole, and my lack of knowledge has left my googling insufficient. I need to control about 20 5mm yellow LEDs with a Teensy 4.1, and have them turn on and off randomly. I've got a working version with 4 LEDs, but they're all getting power via the Teensy's GPIO pins. It's my understanding the Teensy wouldn't be able to power all 20, so I'm planning to use external power. My question is how can I still individually toggle the LEDs on and off with the Teensy while using external power? Any general guidance would be greatly appreciated, sorry for my lack of knowledge!
you could use addressable strings (search: NEOPIXEL) (up to hundreds, with care)
you could use an I2C port expander and put an LED on each output (16 per unit)
you could use something like a MAX7219, and arrange your LEDs as you want, but wire them as if they were a matrix. (64 maximum)
Up to a point, with significant design restrictions, any one of the above will do what you want, but there's no really easy answer unless you change to a MEGA2560 and just wire your 20 LEDs to it's outputs. Even there, you begin to get to the limits of available output current, if you decide to put anything else on all the spare outputs.
With daisy-chained shift registers you can control an almost unlimited number of LEDs with just 3 output-pins.
I have a project with a different MAX chips, the MAX 6968. They are basically special-purpose shift registers designed for driving LEDs. They have built-in current limiting so the LEDs don't need resistors.
My project uses 6 of these chips to control 48 LEDs (with just 3 connections).
NeoPixel/WS2812 LEDs have a driver built-in to the LED any you can control many-many LEDs with just one data connection. They are generally RGB but you can send "yellow" data. You need a software library but the hardware wiring couldn't be easier!