From Code to Mechanics: I’m Stumped

In my desire to use code to create artwork, I decided I need to learn how to use code to control actual real-world devices. Lets say for instance I have some code that outputs the number 10. How would I go about making that number make an led flash 10 times

This is just an example of course and could be turned into anything, but it is a start and would be a huge start. When I write code I know it will output a .swf, or a .html, etc.. I know my output. But what if I want my output to be light, or an action by a machine. I don’t even know where to begin.

This isn’t rhetorical. I am asking everyone. How can I get a program such as flash, or processing to output to a real-world devices?