Last active
December 22, 2015 00:38
-
-
Save VincentK16/6390286 to your computer and use it in GitHub Desktop.
Mini Piano V1.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int speaker = 13; | |
int button_1 = 0; | |
int button_2 = 1; | |
int button_3=2; | |
int button_4 = 3; | |
int button_5 = 4; | |
int button_6=5; | |
int button_7=6; | |
int button_8=7; | |
int button_9=8; | |
int button_10=9; | |
int button_11=10; | |
int button_12=11; | |
int button_13=12; | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize the digital pin as an output. | |
pinMode(speaker,OUTPUT); | |
pinMode(0,INPUT); | |
pinMode(1,INPUT); | |
pinMode(2,INPUT); | |
pinMode(3,INPUT); | |
pinMode(4,INPUT); | |
pinMode(5,INPUT); | |
pinMode(6,INPUT); | |
pinMode(7,INPUT); | |
pinMode(8,INPUT); | |
pinMode(9,INPUT); | |
pinMode(10,INPUT); | |
pinMode(11,INPUT); | |
pinMode(12,INPUT); | |
digitalWrite(0,HIGH); | |
digitalWrite(1,HIGH); | |
digitalWrite(2,HIGH); | |
digitalWrite(3,HIGH); | |
digitalWrite(4,HIGH); | |
digitalWrite(5,HIGH); | |
digitalWrite(6,HIGH); | |
digitalWrite(7,HIGH); | |
digitalWrite(8,HIGH); | |
digitalWrite(9,HIGH); | |
digitalWrite(10,HIGH); | |
digitalWrite(11,HIGH); | |
digitalWrite(12,HIGH); | |
noTone(13); | |
} | |
// the loop routine runs over and over again forever: | |
void loop() { | |
if(digitalRead(0) == LOW) | |
{tone(13,262); | |
} | |
else if(digitalRead(1) == LOW) | |
{tone(13,294); | |
} | |
else if(digitalRead(2) == LOW) | |
{tone(13,330); | |
} | |
else if(digitalRead(3) == LOW) | |
{tone(13,349); | |
} | |
else if(digitalRead(4) == LOW) | |
{tone(13,392); | |
} | |
else if(digitalRead(5) == LOW) | |
{tone(13,440); | |
} | |
else if(digitalRead(6) == LOW) | |
{tone(13,494); | |
} | |
else if(digitalRead(7) == LOW) | |
{tone(13,523); | |
} | |
else if(digitalRead(8) == LOW) | |
{tone(13,277); | |
} | |
else if(digitalRead(9) == LOW) | |
{tone(13,311); | |
} | |
else if(digitalRead(10) == LOW) | |
{tone(13,370); | |
} | |
else if(digitalRead(11) == LOW) | |
{tone(13,415); | |
} | |
else if(digitalRead(12) == LOW) | |
{ | |
tone(13,466); | |
} | |
else | |
{ | |
noTone(13); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment