Advertisement
Trainlover08

Transmission code attempt

May 24th, 2023 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.02 KB | None | 0 0
  1. include<iosteam>
  2.  
  3. int Laxle_speed = 0;
  4. int Raxle_speed = 0;
  5. int Left_Bank_rpm = 0;
  6. int Right_Bank_rpm = 0;
  7. int Left_Bank_power = 0;
  8. int Right_Bank_power = 0;
  9. int gear = 1;
  10. bool PTOtoggle = false;
  11.  
  12.  
  13. int main() {
  14.     // Initializing the VEX Brain and a solenoid instance
  15.     vex::brain Brain;
  16.     vex::solenoid Solenoid[] = {vex::solenoid(A), vex::solenoid(B), vex::solenoid(C), vex::solenoid(D), vex::solenoid(E), vex::solenoid(F)};
  17.  
  18.     // Variable to track the solenoid state
  19.     bool solenoidStates[] = {false, false, false, false, false, false};
  20.  
  21.  
  22. void Gear1{
  23.   bool solenoidStates[] = {true, true, false, false, false, false};
  24.   gear = 1;
  25. }
  26.  
  27. void Gear2{
  28.   bool solenoidStates[] = {false, true, true, false, false, false};
  29.   gear = 2;
  30. }
  31.  
  32. void Gear3{
  33.   bool solenoidStates[] = {false, false, true, true, false, false};
  34.   gear = 3;
  35. }
  36.  
  37. void Gear4{
  38.   bool solenoidStates[] = {false, false, false, true, true, false};
  39.   gear = 4;
  40. }
  41.  
  42. void Aux1{
  43.   bool solenoidStates[] = {false, false, false, false, true, true};
  44.   gear = -1;
  45. }
  46.  
  47. void Aux2{
  48.   bool solenoidStates[] = {false, false, false, false, false, true};
  49.   gear = -2;
  50. }
  51.  
  52. void Aux3{
  53.   bool solenoidStates[] = {false, false, false, false, false, false};
  54.   gear = -3;
  55. }
  56.  
  57. void UpShift{
  58.   if(PTOtoggle = false){
  59.      
  60.   if(gear == 1){
  61.       Gear2;
  62.     }
  63.   if(gear == 2){
  64.       Gear3;
  65.     }
  66.   if(gear == 3){
  67.       Gear4;
  68.     }
  69.   } else {
  70.   if(gear == -3){
  71.      Aux2;
  72.     }
  73.   if(gear == -2){
  74.      Aux1;
  75.     }
  76.   }
  77.  
  78. void DownShift{
  79.   if(PTOtoggle = false){
  80.      
  81.   if(gear == 2){
  82.       Gear1;
  83.     }
  84.   if(gear == 3){
  85.       Gear2;
  86.     }
  87.   if(gear == 4){
  88.       Gear3;
  89.     }
  90.   } else {
  91.   if(gear == -2){
  92.      Aux3;
  93.     }
  94.   if(gear == -1){
  95.      Aux2;
  96.     }
  97.   }
  98.    
  99.    
  100. while (true){  //repeat indefinitely
  101.  
  102.   if (Brain.Controller1.ButtonR1.pressing()) {
  103.     UpShift;
  104.   }
  105.   if (Brain.Controller1.ButtonR2.pressing()) {
  106.     DownShift;
  107.   }
  108.   if (Brain.Controller1.ButtonB.pressing()) {
  109.       PTOtoggle =! PTOtoggle;
  110.   }
  111.  
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement