Skip to content

Instantly share code, notes, and snippets.

@Ryoga-exe
Created December 8, 2023 13:04
Show Gist options
  • Save Ryoga-exe/94a66134c5b5be2aef1acc70e63e1df2 to your computer and use it in GitHub Desktop.
Save Ryoga-exe/94a66134c5b5be2aef1acc70e63e1df2 to your computer and use it in GitHub Desktop.
Play Yobikomi-kun with Arduino
byte step=2; //ピン番号は適当に実配線と合わせる
byte dir=5; //ピン番号は適当に実配線と合わせる
#define D 587
#define E 659
#define F 739
#define G 783
#define A 880
#define B 987
#define a 225
#define b 450
#define c 675
#define d 900
#define e 1800
#define play(s, p, q) tone(s, p, q); delay(q); noTone(step);
#define sleep(s, q) delay(q);
void setup() {
pinMode(step,OUTPUT);
pinMode(dir,OUTPUT);
delay(1000);
}
void loop() {
int m = 3;
while(m--) {
play(step,A,a); play(step,A,b); play(step,B,a);
play(step,A,a); play(step,F,a); play(step,A,b);
play(step,A,a); play(step,A,b); play(step,B,a);
play(step,A,a); play(step,F,a); play(step,A,b);
play(step,D,a); play(step,D,a); play(step,D,a); play(step,E,a);
play(step,F,c); play(step,D,a); play(step,F,c); play(step,A,a); play(step,A,d);
play(step,D,a); play(step,D,a); play(step,D,a); play(step,E,a); play(step,F,d);
play(step,D,a); play(step,D,a); play(step,D,a); play(step,E,a); play(step,F,d);
play(step,E,a); play(step,E,a); play(step,E,a); play(step,D,a);
play(step,E,b); play(step,F,b); play(step,A,b); play(step,G,b);
play(step,F,b); play(step,E,b);
}
play(step,A,a); play(step,A,b); play(step,B,a);
play(step,A,a); play(step,F,a); play(step,A,b);
play(step,A,a); play(step,A,b); play(step,B,a);
play(step,A,a); play(step,F,a); play(step,E,b);
play(step,D,e);
noTone(step);
while(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment