How to Make Your Own Piano Game

39130

Intro: How to Make Your Own Piano Game

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.

STEP 1: Wireing

Wire the components together like the schematic.

STEP 2: 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); }

STEP 3: Downloads: