https://developer.arm.com/tools-and-software/open-source-sof...
But when you write a program for a microcontroller, you don't have an OS kernel, so your code needs to include drivers for anything that you want to communicate with.
It's a little outdated, but I like this introduction to STM8 chips (which this article also mentions) as a quick crash course on embedded C:
And the advantage that dirt cheap clone boards exist. There's huge starter kits in Aliexpress at $10-$20 range, with an arduino uno or mega2560 clone included.
if(user_has_pressed_out_of_milk_button) {
...
} //??EDIT: Follow the better suggestion from harry8 below.
https://www.aliexpress.com/item/33059632653.html
I found that stupidly simple with many, many libraries to do things. WS2812 LED strips using FastLED is very popular and rightly so, great fun. Really quick and easy to start flashing lights in patterns. Then copy some wifi code so you can control it with your phone (or tablet or laptop). Mesh more than one. If you're just playing $3 is still very cheap.
And if you've just started learning C being arduino compatible with many step-by-step tutorials a search away is gold.
ESP8266 successor is ESP32. Also on Aliexpress, cheap and easy to get, ESP32-PICO-KIT and ESP32-DevKitC.
I doubt that's the most efficient route these days, but it can still be fun. And there's lots of material on the likes of the Commodore 64.
Oh, and of course there's always Google: 'but how do you learn to work/program for microcontrollers?' gets lots of hits, I bet some of them are even good.