1, 2, 3 testing, testing…
Here we go!
You will need:
- 1 x ZumBloq LED
- A ZUM BT 328 controller board or one compatible with Arduino UNO
- A USB cable
Remember the previous lesson where you learnt what a loop is and how the while block works? Well then, this block is also a loop, but instead of repeating itself while a condition is fulfilled, the program will repeat the orders a certain number of times. To do this, you will need to tell the block that count, from and up until which number. We will see how it works with a very simple example:
The program lights up the LED for a certain length of time, increasing it each time by one second, so that it lights up the first time for one second, the second time for two seconds, the third for three seconds and so on, until reaching ten seconds. To do this, we will use the count block. In this block you need to configure three values, the first one, count with [value], is where you will state which variable you are going to count with, in our case it´s the count variable. The second one, from [value], is where we must state which number we want to start counting from, we can start to count from zero, one, or ten – basically whichever value you want. Finally the to [value] allows you to define what number you want to count up to. You can count upwards in increasing values… Or backwards counting down! If your initial value is greater than the final one, for example, counting down from 10 to 1, the program will subtract values until it reaches 1. The count loop has loads of uses, but the best one is… You´ll never need to use your hands again! Can you think of any uses? How about creating a machine to count automatically when you play hide and seek? You could make an LED light up each second and sound a buzzer when it gets to 100… Try it!