This week we kicked the term of by programming a stopwatch. So no building the first week, which invariably dissapoints some of the more building orientated kids. Since most of the children attended last term, everyone is more or less on the same skill level.

A stopwatch can be a suprisingly difficult concept to program. There are probably  a number of different ways to solve this problem. We did it as far as possible from first principles. So you basically have a loop that counts the number of seconds that pass. That loop is then incapsulated in successive loops for minutes, hours, days etc.

This is the most basic example. It only records seconds.

Following is the most complicated one we did in class. You can expand this in both directions even further, but you will eventually run into the limitations of the processor on the finer measurements of time and you will most likely run out of battery on the larger measurements.




You Might Also Like