In this lesson, we are going to explore some of the coding concepts for the Auto watering project you are going to code next. Take a look at the blocks below, they will be used to code your project in the next section.

Conditional Statements (If/Then)

There are times when we want our computer to do something only when a specific condition is true. We can use a special block called “conditional statements” or “If-Then” block for that. It’s a bit like this: If it’s library day, then you bring your library book. When you have a block nested in the If-Then block, the computer will know to output that block…but only when your condition is true!*Troubleshooting tip. If a conditional statement isn’t outputting as desired, make sure it is nested in a Forever Loop. This will evaluate the condition over and over again while the program is running. Otherwise, it will only evaluate the condition one time upon starting the program.

Forever Loop

Sometimes, you might want something to keep happening again and again. Instead of writing many lines of code, we can use something called a “loop” in our code. Imagine a “Forever Loop” as a magical tool that makes any block nested inside, repeat over and over and over, just like magic that never ends! This is called a repeating event. This makes the code more efficient by minimizing the lines of code.