Skip to content

HAT-022 Touch Piano ​

Instance declaration ​

When you add a HAT-022 Touch Piano block to the workspace, the following instance declaration is automatically inserted into the Python code:

python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()

Parameters ​

NameKindDescriptionRange / TypeDefault
indexDropdown optionInstance number (starting from 0)Integer 0 or greater0

Start the touch piano ​

Uses the touch piano.

start

Parameters ​

(none)

Python ​

python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()

hat022.start()

Key input value ​

The input state of the selected key
It outputs 1 if the key is pressed, and 0 if the key is not pressed.

key_input

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionNote keyDo (C), Do# (C#), Re (D), Re# (D#), Mi (E), Fa (F), Fa# (F#), Sol (G), Sol# (G#), La (A), La# (A#), Si (B), ◀ (left), ▶ (right), fn (fn)-

Python ​

python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()

hat022.key_input('C')

Is the key pressed? ​

Whether the selected key was clicked

key_pressed

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionNote keyDo (C), Do# (C#), Re (D), Re# (D#), Mi (E), Fa (F), Fa# (F#), Sol (G), Sol# (G#), La (A), La# (A#), Si (B), ◀ (left), ▶ (right), fn (fn)-

Python ​

python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()

hat022.key_pressed('C')