Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. if(decyzja=='P' || decyzja=='p')
  2. {
  3.     int i=10;
  4.     NXT::Sensor::SetColor(&comm, IN_1, 'n');
  5.     int color;
  6.     int stare;
  7.     int obecny;
  8.     while(True)
  9.     {
  10.         color =NXT::Sensor::GetValue(&comm, IN_1);
  11.         while(color<130)
  12.         {
  13.             NXT::Motor::SetForward(&comm, OUT_B, x);
  14.             NXT::Motor::SetForward(&comm, OUT_C, x);
  15.             color =NXT::Sensor::GetValue(&comm, IN_1);
  16.         }
  17.         stare=NXT::Sensor::GetSonarValue(&comm, IN_3);
  18.         if(stare+i>179)
  19.             stare=stare+i-179;
  20.         else if(stare-i<0)
  21.             stare=stare-i+179;
  22.         obecny=NXT::Sensor::GetSonarValue(&comm, IN_3);
  23.         while(stare+i!=obecny && color >=130)
  24.         {
  25.             NXT::Motor::SetReverse(&comm, OUT_C, y);//prawo
  26.             NXT::Motor::SetForward(&comm, OUT_B, y);                    
  27.             obecny=NXT::Sensor::GetSonarValue(&comm, IN_3);
  28.             color =NXT::Sensor::GetValue(&comm, IN_1);
  29.         }
  30.         while(stare-i!=obecny && color >=130)
  31.         {
  32.             NXT::Motor::SetReverse(&comm, OUT_B, y);//prawo
  33.             NXT::Motor::SetForward(&comm, OUT_C, y);                    
  34.             obecny=NXT::Sensor::GetSonarValue(&comm, IN_3);
  35.             color =NXT::Sensor::GetValue(&comm, IN_1);
  36.         }
  37.         i=i+5;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement