Advertisement
djazz

CraneTank - Crane's NXC source

Sep 10th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. task updateMotors () {
  2.    
  3.     string buffer, message = "";
  4.     char result;
  5.     while (1) {
  6.        
  7.         // read mailbox
  8.         result = ReceiveMessage(0, true, buffer);
  9.         if (result == 0) {
  10.             message = buffer;
  11.             bool gotMotorMessage = true;
  12.  
  13.             switch (message) {
  14.                 case "TurnLeft": OnRev(OUT_B, 50); break;
  15.                 case "TurnRight": OnFwd(OUT_B, 50); break;
  16.                 case "TurnStop": Off(OUT_B); break;
  17.                
  18.                 case "TiltUp":  OnFwd(OUT_C, 50); break;
  19.                 case "TiltDown": OnRev(OUT_C, 50); break;
  20.                 case "TiltStop": Off(OUT_C); break;
  21.  
  22.                 case "ClawIn":  OnFwd(OUT_A, 80); break;
  23.                 case "ClawOut": OnRev(OUT_A, 80); break;
  24.                 case "ClawStop": Off(OUT_A); break;
  25.  
  26.                 default: gotMotorMessage = false; break;
  27.             }
  28.  
  29.             if (gotMotorMessage) {
  30.                 TextOut(0, LCD_LINE3, "Motor: "+message+"       ");
  31.             }
  32.            
  33.         }
  34.        
  35.         Wait(50);
  36.  
  37.     }
  38. }
  39.  
  40. task main() {
  41.  
  42.     Precedes(updateMotors);
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement