In this project you will create a timer that reports the number of seconds elapsed in both decimal and binary notations.
You can visit this wikihow.com page and discuss conversion from base 10 to base 2.
Note that there are two methods presented in the link.
Get Binary Digits
block (in Timer) is the only place where you will need to fill in some code.
If you look at the Timer sprite code, you will see that the timer
block (from the "Sensing" menu) is used as a time keeper. The decimal and binary digits are computed and stored in lists, and then a broadcast is made to the sprites representing the digits to put on the appropriate costumes (0 and 1 for the binary digits and 0 through 9 for the decimal digits.)
The "warp" block is used to ensure that all the computation within the block is completed prior to the refreshing of the screen .
The code for extracting the base 10 digits of a given number,Get Decimal Digits
, is written for you. If you are using method 2 (Descending Powers of Two and Subtraction) to write Get Binary Digits
you can ignore the code in Get Decimal Digits
. If you are using method 1 (Short Division by Two with Remainder) however, you can use this code as a model to write the Get Binary Digits
code as it is based on method 1.
Get Binary Digits
custom block using either conversion method. If you get stuck, you can get some hints for the Binary Timer project. When you are done, review the code for the sprites representing the 8 binary digits. Check that the timer works in the binary notation. current
time block in the "Sensing" menu: