Created
January 11, 2012 02:21
-
-
Save y-yu/1592582 to your computer and use it in GitHub Desktop.
あるでぃーの
This file contains 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 spk = 13; | |
//int doremi[] = {523, 587, 659, 698, 784, 880, 988, 1046}; | |
int doremi[] = {478, 506, 568, 638, 716, 758, 851, 956}; | |
int button[8]; | |
void setup() { | |
button_init(); | |
pinMode(spk, OUTPUT); | |
} | |
void loop() { | |
for (int i=0; i<8; i++) { | |
while (digitalRead(button[i]) == LOW) { | |
digitalWrite(spk, HIGH); | |
delayMicroseconds(doremi[i]); | |
digitalWrite(spk, LOW); | |
delayMicroseconds(doremi[i]); | |
} | |
digitalWrite(spk, LOW); | |
} | |
} | |
void button_init() { | |
for (int i=0; i<8; i++) { | |
button[i] = i + 4; | |
Serial.println(i); | |
pinMode(button[i], INPUT); | |
digitalWrite(button[i], HIGH); | |
} | |
} |
This file contains 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 spk = 13; | |
//int doremi[] = {523, 587, 659, 698, 784, 880, 988, 1046}; | |
int doremi[] = {478, 506, 568, 638, 716, 758, 851, 956}; | |
int button[8]; | |
void setup() { | |
button_init(); | |
pinMode(spk, OUTPUT); | |
} | |
void loop() { | |
for (int i=0; i<8; i++) { | |
while (digitalRead(button[i]) == LOW) { | |
digitalWrite(spk, HIGH); | |
delayMicroseconds(doremi[i]); | |
digitalWrite(spk, LOW); | |
delayMicroseconds(doremi[i]); | |
} | |
digitalWrite(spk, LOW); | |
} | |
} | |
void button_init() { | |
for (int i=0; i<8; i++) { | |
button[i] = i + 4; | |
Serial.println(i); | |
pinMode(button[i], INPUT); | |
digitalWrite(button[i], HIGH); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment