#define A 123 #define B 234 #define C 345 #define D 456 #define E 567 #define F 678 #define G 789 #define H 890 #define I 901 #define P PlayTone #define W Wait task main() { while(true) { P(E,20);W(40); P(D,20);W(30); P(C,20);W(40); P(B,10);W(30); P(A,10);W(20); *試作品 [#g94de956] #define DO1 880 #define DO01 932 #define RE1 988 #define MI1 1047 #define MI01 1109 #define FA1 1175 #define FA01 1245 #define SO1 1319 #define LA1 1397 #define LA01 1480 #define SHI1 1568 #define SHI01 1661 #define DO2 1760 #define P PlayTone #define W Wait task play_music() { while(true) { P(RE1,10);W(10); P(MI1,10);W(10); P(FA1,10);W(10); P(SO1,10);W(10); P(LA1,10);W(20); P(LA1,10);W(10); P(SO1,10);W(10); P(FA1,10);W(10); P(MI1,10);W(10); P(RE1,10);W(20); P(RE1,10);W(10); P(MI1,10);W(10); P(FA1,10);W(10); P(SO1,10);W(10); P(LA1,5);W(5); P(LA1,5);W(10); P(LA1,10);W(10); P(SO1,10);W(10); P(FA1,10);W(10); P(MI1,10);W(10); P(DO01,25);W(30); } } #define A 123 #define B 234 #define C 345 #define D 456 #define E 567 #define F 678 #define G 789 #define H 890 #define I 901 task play_music2() { while(true) { P(E,20);W(40); P(D,20);W(30); P(C,20);W(40); P(B,10);W(30); P(A,10);W(20); P(A,20); W(30); P(C,5); W(10); P(D,20); W(25); P(F,20); W(25); P(E,20); W(25); P(D,10);W(25); P(C,5);W(10); P(C,10);W(10); P(C,5);W(10); P(C,10);W(10); } } #define turn_right OnFwd(OUT_A);OnRev(OUT_C); #define turn_left OnRev(OUT_A);OnFwd(OUT_C); #define stop_turning Off(OUT_A+OUT_C); #define TURN_TIME 400 #define go OnFwd(OUT_A+OUT_C); task main () { task main () SetSensor(SENSOR_1,SENSOR_LIGHT); SetSensor(SENSOR_3,SENSOR_LIGHT); ClearTimer(0); turn_right; start play_music; while(FastTimer(0)<TURN_TIME){ if((SENSOR_1>light_max)||(SENSOR_3>light_max)) { light_max=SENSOR_1 || light_max=SENSOR_3; time_max=FastTimer(0); } } stop_turning; stop play_music; Wait(100); OnFwd(OUT_C);OnRev(OUT_A); Wait(TURN_TIME-time_max); Off(OUT_A+OUT_C); while(true){ if(SENSOR_1>=light_max){ OnFwd(OUT_A+OUT_C); }else{ start play_music; OnFwd(OUT_A);OnRev(OUT_C); until(SENSOR_1>=light_max); stop play_music; } } } P(A,20); W(30); P(C,5); W(10); P(D,20); W(25); P(F,20); W(25); P(E,20); W(25); P(D,10);W(25); P(C,5);W(10); P(C,10);W(10); P(C,5);W(10); P(C,10);W(10); } }