Skip to content.

Sections
Personal tools
You are here: Home Members mchang Behavior program 1
Document Actions

Behavior program 1

by Max Chang last modified 2007-02-05 09:53 AM

first program from the Attributing Behavior assignment

#define POWER 1

task main()

{

     SetSensorType ( SENSOR_1 , SENSOR_TYPE_LIGHT );

     SetSensorType ( SENSOR_3 , SENSOR_TYPE_LIGHT );

    

     int start_1 = SENSOR_1 ;

    

     while (1)

    {

         Off ( OUT_A + OUT_C );

         if ( SENSOR_1 >start_1)

        {

             SetPower ( OUT_A , 1 * POWER);

             SetPower ( OUT_C , 0);

             OnFwd ( OUT_A );

        }

         else

        {

             SetPower ( OUT_A , 1 * POWER);

             SetPower ( OUT_C , 2 * POWER);

             OnFwd ( OUT_A + OUT_C );

        }

    }

}

 

Powered by Plone, the Open Source Content Management System