The Basics
In this chapter, this tutorial will walk you through the basic program control flow found in most programming languages. For example, if we want a program to make decisions based on the current temperature — say, turning on the air conditioner when the temperature exceeds 30 degrees — then we need to check a condition: is the current temperature greater than some number? If the answer is yes, turn on the air conditioner; if the answer is no, do something else. Although this chapter won’t teach you how to actually hook your program up to an air conditioner, you will at least learn how to write conditional checks in the language. Or perhaps you’d like to make an LED blink once per second. In that case, what we need is to tell the computer to repeat an action over and over: light on, light off. Likewise, this chapter won’t teach you how to connect your program to an LED — it won’t even teach you how to wait one second — but you will learn how to tell the computer to perform an operation repeatedly.