Counter and timer in Lego Wedo 2.0

Counter and timer in Lego Wedo 2.0

In programming, many typical tasks have standard solutions. A good example of such tasks is the time counting in both sides - a counter and a timer. Often, as part of the algorithm either need to count the time, or wait for a certain period of time to elapse. In our material, we consider both cases.

Counter on WeDo 2.0 Toolbox

To program a counter algorithm from 0 to 10 in the WeDo 2.0 toolbox, you will need:

1) Set a white background to the block «Display Background» (number «0»). 

 

 2) Set the « Display Block, 123» to the initial value from which the count will be taken (usually the value is «0»). This is the operation that programmers call initialization. 

 

 3) Set the number of repetitions for the loop (Repeat Block), for example, - 10 times.  


 4) Each time the cycle is repeated, add «+1» to the value recorded in the screen memory. In turn, this command in programming is called an increment. 


5) Set a "Wait for" block with a value of 1 second.

    Counter from 0 to 10

    Timer on WeDo 2.0 Toolbox

    To program a timer algorithm from 0 to 10 in the WeDo 2.0 toolbox, you will need:

    1) Set a white background to the block «Display Background» (number «0»).

     

    2) Set the « Display Block, 123» to the initial value from which the count will be taken (in our case the value is «10»). This is the operation that programmers call initialization.  

     

    3) Set the number of repetitions for the loop (Repeat Block), for example, - 10 times.  

     

    4) Each time the cycle is repeated, subtract «-1» from the value recorded in the screen memory. In turn, this command in programming is called a decrement.  

     

    5) Set a "Wait for" block with a value of 1 second

      Timer from 10 to 0

      Learn the basics of programming yourself or read our blog! And also do not miss new materials both about kit Lego WeDo 2.0 and useful life hacks from the Lego WeDo toolbox.