目次
#contents

*光を追いかけるロボット [#yd54c69c]

*工夫した点 [#t6859809]


*プログラム(試作1号) [#h41564b4]
製作 ソウマ
 #define stop_turning Off(OUT_A+OUT_C);
 #define turn_right OnFwd(OUT_A);OnRev(OUT_C);
 #define turn_left OnFwd(OUT_C);OnRev(OUT_A);
 #define TURN_TIME 400
 #define free_TIME 1000
 #define go_turning OnFwd(OUT_A+OUT_C);
 task main()
 {
 SetSensor(SENSOR_1,SENSOR_LIGHT);
 SetSensor(SENSOR_3,SENSOR_LIGHT);
 int light_max=0,time_max=0;
 turn_right;
 ClearTimer(0);
 ClearTimer(1);
 while(FastTimer(0)<TURN_TIME){
 if(SENSOR_1>light_max){
 light_max=SENSOR_1;
 time_max=FastTimer(0);
 }
 }
 stop_turning;
 Wait(60);
 turn_left;
 Wait(TURN_TIME-time_max);
 stop_turning; 
 while(FastTimer(1)> free_TIME){
 if(SENSOR_1< SENSOR_3){
 turn_right;
 Wait(20); 
 }
 else{
 turn_left;
 Wait(20);
 }
 }  
 }

*プログラム2 [#gc24937d]
 #define stop_turning Off(OUT_A+OUT_C);
 #define turn_right OnFwd(OUT_A);OnRev(OUT_C);
 #define turn_left OnFwd(OUT_C);OnRev(OUT_A);
 #define TURN_TIME 400
 #define free_TIME 1000
 #define go_go OnFwd(OUT_A+OUT_C);
 task main()
 {
 SetSensor(SENSOR_1,SENSOR_LIGHT);
 SetSensor(SENSOR_3,SENSOR_LIGHT);
 while(1+1==2){
 if(SENSOR_1>70){go_go;}
 else
 {
 int light_max=0,time_max=0;
 turn_right;
 ClearTimer(0);
 ClearTimer(1);
 while(FastTimer(0)<TURN_TIME){
 if(SENSOR_1>light_max){
 light_max=SENSOR_1;
 time_max=FastTimer(0);
 }
 }
 stop_turning;
 Wait(60);
 turn_left;
 Wait(TURN_TIME-time_max);
 stop_turning; }
 }
 }
*暫定メリーさんバージョン [#r7488642]
 #define stop_turning Off(OUT_A+OUT_C);
 #define turn_right OnFwd(OUT_A);OnRev(OUT_C);
 #define turn_left OnFwd(OUT_C);OnRev(OUT_A);
 #define TURN_TIME 400
 #define free_TIME 1000
 #define go_go OnFwd(OUT_A+OUT_C); 
 #define Do  523
 #define Re  587
 #define Mi  659
 #define Fa  698
 #define Sol 784 
 task play_music()   // 音楽を演奏するタスク
 while (true)
 {
 PlayTone(Mi,25); Wait(30);  // Wait の時間の方を少し長くし  て
 PlayTone(Re, 5); Wait(10);  // 同じ音を続けて鳴らす場合に も
 PlayTone(Do,15); Wait(20);  // 一つの音にならないようにしている
 PlayTone(Re,15); Wait(20);
 PlayTone(Mi,15); Wait(20);
 PlayTone(Mi,15); Wait(20);
 PlayTone(Mi,35); Wait(40);
 PlayTone(Re,15); Wait(20);
 PlayTone(Re,15); Wait(20);
 PlayTone(Re,35); Wait(40);
 PlayTone(Mi,15); Wait(20);
 PlayTone(Sol,15); Wait(20);
 PlayTone(Sol,35); Wait(40);
 PlayTone(Mi,25); Wait(30);
 PlayTone(Re, 5); Wait(10);
 PlayTone(Do,15); Wait(20);
 PlayTone(Re,15); Wait(20);
 PlayTone(Mi,15); Wait(20);
 PlayTone(Mi,15); Wait(20);
 PlayTone(Mi,35); Wait(40);
 PlayTone(Re,15); Wait(20);
 PlayTone(Re,15); Wait(20);
 PlayTone(Mi,25); Wait(30);
 PlayTone(Re, 5); Wait(10);
 PlayTone(Do,55); Wait(60);
 Wait(20);
 }
 }
 task main()
 {
 SetSensor(SENSOR_1,SENSOR_LIGHT);
 SetSensor(SENSOR_3,SENSOR_LIGHT);
 while(1+1==2){
 if(SENSOR_1>50){go_go;}
 else
 {
 int light_max=0,time_max=0;
 turn_right;
 ClearTimer(0);
 ClearTimer(1);
 while(FastTimer(0)<TURN_TIME){
 start play_music ;
 if(SENSOR_1>light_max){
 light_max=SENSOR_1;
 time_max=FastTimer(0);
 }
 }
 stop_turning;
 Wait(60);
 turn_left;
 Wait(TURN_TIME-time_max);
 stop_turning; 
 stop play_music ;}
 }
 } 

*コメント [#h8efc1fa]


#comment

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS