Skip to content

Gweithgaredd

Gitâr 1 - tonau cyffwrdd

Uwch | MakeCode, Python | Pinnau, Sain | Electroneg, Mewnbwn/allbwn, Sain, Trydan

Cam 1: Gwneud

Beth yw e?

Play different tunes by using the micro:bit’s touch sensor.

Mae'r ddau fideo hyn yn dangos i chi yr hyn y byddwch yn ei greu a sut i'w godio:

Cyflwyniad

Canllaw codio

Sut mae'n gweithio

  • This project is the same as the Jukebox project but instead of using the micro:bit’s buttons, you’ll make your own input device using cardboard covered in strips of tin foil connected by crocodile clip leads to the micro:bit's pins.
  • Flash the program onto your micro:bit.
  • Attach one end of three crocodile clip leads to pins 1, 2 and GND (ground or Earth pin). Attach the other ends to a cardboard guitar or keyboard.
  • With one finger touch the foil connected to GND, and with another finger touch the foil connected to pin 1 and then pin 2. It should play a different tune depending on which strip of foil you touch.
  • The micro:bit is using pins 1 and 2 as touch inputs. When you touch either of these pins and the GND pin, you’re completing an electrical circuit. A small amount of electricity flows through you, the micro:bit can detect it and the program triggers the playing of a tune.
  • If you do not have a V2 micro:bit, which plays sound, attach headphones to pins 0 and GND.
llun yn dangos sut i gysylltu padiau ffoil arian â phinnau micro:bit 1, 2 a GND

Beth sydd ei angen arnoch

  • micro:bit a phecyn batri opsiynol
  • Golygydd MakeCode neu Python
  • three crocodile clip leads
  • cardboard, tin foil, glue stick and scissors to make a guitar or keyboard
  • optional headphones, buzzer, or speaker with additional two crocodile clip leads for V1 users

Cam 2: Codio

1from microbit import *
2import music
3
4while True:
5    if pin1.is_touched():
6        music.play(music.ODE)
7    if pin2.is_touched():
8        music.play(music.BLUES)
9

Cam 3: Gwella

  • Change the tunes that are played when you touch the tin foil.
  • Rhaglennu eich tonau eich hun.
  • Show different pictures, letters, numbers, or words depending on which tune you picked.
Ariennir gan Lywodraeth Cymru / Funded by Welsh Government

Translation generously supported by the Welsh Government.