kohacraft Lab
/
kc_piano
electric piano
Revision 0:27e5e1ab3286, committed 2015-11-06
- Comitter:
- kohacraft
- Date:
- Fri Nov 06 04:18:36 2015 +0000
- Commit message:
- ver1.0;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 27e5e1ab3286 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Nov 06 04:18:36 2015 +0000 @@ -0,0 +1,152 @@ +#include "mbed.h" + + +PwmOut sp(dp1);//スピーカー +DigitalIn c1(dp2); +DigitalIn cis1(dp4); +DigitalIn d1(dp6); +DigitalIn dis1(dp9); +DigitalIn e1(dp10); +DigitalIn f1(dp11); +DigitalIn fis1(dp13); +DigitalIn g1(dp14); +DigitalIn gis1(dp15); +DigitalIn a1(dp16); +DigitalIn b1(dp17); +DigitalIn h1(dp18); +DigitalIn c2(dp24); +DigitalIn modesw(dp25); + +int main() { + float piano; + float p1; + float mode; + mode = 1; + sp.period(0.00001); + piano = 0.01;//0.01普通 数字を大きくすると早くなる + while(1) { + if(modesw == 1){ + mode += 1; + } + if(mode == 4){ + mode = 1; + } + if(mode == 1){ + piano = 0.01; + } + if(mode == 2){ + piano = 0.1; + } + if(mode == 3){ + piano = 1.0; + } + if(c1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/523.25); + sp = 0; + wait(1.0/523.25); + } + } + if(cis1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/554.37); + sp = 0; + wait(1.0/554.37); + } + } + if(d1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/587.33); + sp = 0; + wait(1.0/587.33); + } + } + if(dis1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/622.25); + sp = 0; + wait(1.0/622.25); + } + } + if(e1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/659.26); + sp = 0; + wait(1.0/659.26); + } + } + if(f1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/698.46); + sp = 0; + wait(1.0/698.46); + } + } + if(fis1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/739.99); + sp = 0; + wait(1.0/739.99); + } + } + if(g1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/783.99); + sp = 0; + wait(1.0/783.99); + } + } + if(gis1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano) { + sp = p1; + wait(1.0/830.61); + sp = 0; + wait(1.0/830.61); + } + } + if(a1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano/1.5) { + sp = p1; + wait(1.0/440.00/2); + sp = 0; + wait(1.0/440.00/2); + } + } + if(b1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano/1.5) { + sp = p1; + wait(1.0/466.16/2); + sp = 0; + wait(1.0/466.16/2); + } + } + if(h1 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano/1.5) { + sp = p1; + wait(1.0/493.88/2); + sp = 0; + wait(1.0/493.88/2); + } + } + if(c2 == 1){ + for(p1 = 1.0; p1 >= 0.0 ; p1 -= piano/1.5) { + sp = p1; + wait(1.0/523.25/2); + sp = 0; + wait(1.0/523.25/2); + } + } + + + + + } +}
diff -r 000000000000 -r 27e5e1ab3286 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Nov 06 04:18:36 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file