Home > Robots > Half Life > Master Code
 Master Code

/* Master control program for LEGO RoboGladiators */
/* by Dan Danknick 1999 */

int L, R, M;

sub DeadBandL {
  if( (L == 1) || (L == -1))
    L = 0;

  L +-= L;
}

sub DeadBandR {
  if( (R == 1) || (R == -1))
    R = 0;

  R +-= R;
}

task main
{
  IRMode(IR_HI);

  Sensor(IN_1,IN_ANGLE);
  Sensor(IN_2, IN_SWITCH);
  Sensor(IN_3,IN_ANGLE);

  ClearSensor(IN_1);
  ClearSensor(IN_3);

  PlayNote(1500,10);
  
  while(true) {
    L = IN_1;
    R = IN_3;

    DeadBandL();
    DeadBandR();
   
    M=91;
        
    if((L==1) && (R==1))
        M=92;
                
    if((L==-1) && (R==-1))
        M=93;
                
    if((L==-1) && (R==1))
        M=94;
        
    if((L==1) && (R==-1))
        M=95;

// Check for switch that spins the lift
//
    if(IN_2 == 1)
      M += 10;                

    SendMessage(M);
    }
    
}

Copyright © 1996-2001; Team Delta. All Rights Reserved. - Legal Information / Contact / Search