written by itos

Program no.2

This program is made as the second program of the c2-R group.

Function of this program

The machine can trace such strong light as that of a flashlight.

The machine uses two light sensors, which are set light and left.

And the two sensors sense the lightness of the surroundings.

If the lightness of the right side is stronger than that of lest, the machine is programmed to turn right until the left one becomes stronger.

And vise versa.

The machine repeat this choice and movement again and again.

The machine can search strong light when it lose sight of strong light.

If the lightness two both light sensors sense is under 33, this machine stop tracing and go around to search the strongest way of the lughtness.

Then the machine return to the strongest way and go straight.

(The value '33' was not found instantly. We two experimented many times to find the best value to devide tracing light and searching light.)

The machine can ring the sound.

When the machine goes around to search, sound rings.

Plus, this sound is decided by the lightness of the front part of the machine.

I tried this once, but no sound was heard.

So we thought for a long time and found that the sound was extremely high or low.

As a solution of this problem, we decided to use around the center part of the width of the sound the machine can ring.

Other Points

When I use this program for the machine, I change the place of the light sensors.

I place them so that they can sense the light only from the way they are set.

To be concrete, I turned the right sensor to right and left sensor to left.

Thanks to this invention, the tracing of the machine became smoother and more certain.

This is the PROGRAM!

#define THRESHOLD 40           // Decision Standard
#define ROUND 20               // Round Standard
#define DECIDEBORDER 33        // The border value to devide tracing light and searching light.
#define AROUND_TIME 210        // The time the machine takes to round

 int light_strongest ;
 int time_strongest ;
 int sound_height ;

task playsound()

  while (true)
     PlayTone( 3000 - (2000 * sound_height /100) , 100); Wait(110);

task main ()


               light_strongest = SENSOR_1;

   while (true) {
       if (SENSOR_1 < THRESHOLD && ( SENSOR_1 > DECIDEBORDER || SENSOR_2 > DECIDEBORDER )) {     // When the light is stronger on the right side.
           until(SENSOR_1 > THRESHOLD);

       if (SENSOR_3 < THRESHOLD && ( SENSOR_1 > DECIDEBORDER || SENSOR_2 > DECIDEBORDER )) {   //  When the light is stronger on the left side.
           until(SENSOR_3 > THRESHOLD);

       {                                                                  //  Search!
                   sound_height = SENSOR_3;         // Start Sound.
                   start playsound ;


               while(FastTimer(0) < AROUND_TIME)
                    light_strongest = SENSOR_1;
                    time_strongest = FastTimer(0);

               Wait( AROUND_TIME - time_strongest );
                     stop playsound ;



Please give us any comment, wheter it is good or bad.

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2006-07-12 (水) 16:27:34