Users Manual
SCRATCH CODING KIT
TORI Piano, repetition of ‘If~’ block
Do you remember the ‘IF~’ block we used previously? It was the block that activates its internal script when certain
condition was fulfilled. If so, a block of 'if ~ if' will be created for the notes between Do and Si.
That is, seven ‘IF~” block should be connected. So, what happens to the script inside each 'if~' block? They will be
similar to each other. The reason is that if you only need to see the condition of 'Analog Sensor <100', you have
to express the actions (save the beat in the 'Beats' list, play the note, and save the note in the 'note' list). So, if you
make, "If the value of analogue 0 sensor is <100," block, then the only thing you need to do is to make sure that
the script inside the block is accurate.
Then, let’s take a look at which script goes into the “If ‘analog 0 sensor value < 100’.”
Now make a script just like the one above. Do you remember the script that was only able to playback? If you just
add the list portion to that list, it will also be able to record! On the previous page, we made a script so that when
the recording starts, the timer is reset. In the initialized state, there will be no input and the timer will continue to
flow. At this time, if you press the analog 0 button sensor, the timer of that moment will soon be beat. Drag and
drop the block that adds this timer value to the ‘Beats’ list. If you press the button sensor again after this, the in-
terval between the timer will be the length of the beat. Then play the 60th note. Then he 60th note is saved in the
‘note’ list. On the list it is saved and displayed as “C.” In the scale, ‘Do’ is shown as ‘C’, so we set the system to save
‘C’ to save the readability. Also, to play the note only once, we add the “wait until ’analog 0 sensor value >100’”
block. Then we have a script saying "If you press the analog 0 button switch, the time of the timer is added to the
'Beats' list. After playing the 60 notes, add the note to the 'note' list and wait until the button sensor is released.”
TORI Piano coding activity