# Chapter 2: Starting from Bare Metal ## Sample code - Directory: `docs/os-on-arduino/code/02_baremetal` ```bash uv run pio run -d 02_baremetal -t upload uv run pio device monitor -b 115200 ``` ## Source code The sketch for this chapter. Click a file name to expand. The code is mirrored automatically from the manuscript repository, so what you see here is always current. :::{dropdown} `src/main.cpp` — 119 lines :icon: code [Open on GitHub](https://github.com/iory/learning-os-from-arduino/blob/main/docs/os-on-arduino/code/02_baremetal/src/main.cpp) ```{literalinclude} ../../../../code/02_baremetal/src/main.cpp :language: cpp :linenos: ``` ::: ## On the board The Servo task only computes an angle and prints it; it sends no signal to a servo, so you do not need to connect one. ```{figure} ../_static/ch02_tasks.gif :name: fig-ch02-tasks :width: 100% `Servo angle` moves 10 degrees at a time, with `LED` and `Sensor` in between: the three tasks take turns. ``` ## Pitfalls (Collected from reader questions — ask via [GitHub Issues](https://github.com/iory/build-your-own-arduino-rtos/issues).)