How to Make Your Own Piano Game

by simaopintocorreia in Living > Music

490 Views, 3 Favorites, 0 Comments

How to Make Your Own Piano Game

SUNP0015.JPG

It is a small game created by me.

You can play musics in this game ,pushing the buttons ,if you want a more light sound turn the potenciometer or a low frequency sound you just do the same.

Supplies

  1. Arduino
  2. Breadboard
  3. jumpers
  4. 4x Push Buttons
  5. 10K potenciometer
  6. piezo Buzzer
  7. 220 resistor
  8. USB cable

Wireing

thePiano_bb.jpg

Wire the components together like the schematic.

The Code :

Put this code into the Arduino IDE and upload to the board.

#define A 2
#define B 3 #define C 4 #define D 5 #define TONE 9

void setup() { // put your setup code here, to run once: pinMode(A,INPUT); pinMode(B,INPUT); pinMode(C,INPUT); pinMode(D,INPUT);

pinMode(TONE,OUTPUT); pinMode(A0,INPUT); }

void loop() { // put your main code here, to run repeatedly: while (digitalRead(A)==HIGH){ tone(TONE,analogRead(A0)); } while (digitalRead(B)==HIGH){ tone(TONE,(analogRead(A0)+100)); } while (digitalRead(C)==HIGH){ tone(TONE,(analogRead(A0)+150)); } while (digitalRead(D)==HIGH){ tone(TONE,(analogRead(A0)+200)); } noTone(TONE); delay(100); }

Downloads

Downloads:

Downloads