Table of Contents

Touch Piano – Python

Example Description
The example demonstrates using the Quarky touch display to make a touch piano in the Python Coding Mode.

Code

sprite = Sprite('Tobi')
quarky = Quarky()

while True:
  if quarky.ispadtouched("T1"):
    quarky.drawpattern("bbbjjbjjbjjbbjjbjjjbjjbjjjbjjbjjbbb")
    quarky.playtone("C4", 8)

  if quarky.ispadtouched("T2"):
    quarky.drawpattern("cccjcccjcjjjjcjcjjcccjcjjcjjjcjjccc")
    quarky.playtone("D4", 8)

  if quarky.ispadtouched("T3"):
    quarky.drawpattern("fffjfffjfjjjjfjfjjfffjfjjjjfjfjjfff")
    quarky.playtone("E4", 8)

  if quarky.ispadtouched("T4"):
    quarky.drawpattern("dddjdjdjdjjdjdjdjjdddjdjjjjdjdjjjjd")
    quarky.playtone("F4", 8)

  if quarky.ispadtouched("T5"):
    quarky.drawpattern("gggjgggjgjjgjjjgjjgggjgjjjjgjgjjggg")
    quarky.playtone("G4", 8)

Output