Computer graphics course
I am fond of my relatively successful short series of lectures on how OpenGL/DirectX are built. The course can be found here. It is adopted in several universities throughout the world, and is now included in the distribution of Bullet physics library. Also check this C# port made by a team from Microsoft.
I also teach robotics at very different levels, starting from the undergraduate level (introduction to robotics) and going to university (control theory). Here is a small example of what I do in middle schools:
It is a small rover which bounces from obstacles using proximity sensors, but it also tests whether it is stuck by testing odometry. Here is its complete program. This is the main file, it has two threads. One thread is dedicated to test constantly if encoders at the wheels are ticking and if no, then it sends a message to the main thread. Without such a message main thread simply goes forward or calls two subprograms (reverse wheels, then turn).
Here the rover turns using its gyroscope until given angle (90°) is reached:
And this is the obstacle detection thred. It tests a proximity sensor and checks if encoders are still ticking:
Let me give you a small example of what I do in my control theory course. A segway-style inverted pendulum with a PID controller:
Or a Linear-Quadratic Regulator (LQR):