193030

Vibrating motors code

Sep 9th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int actuators = 3;
  6. int stepsCount = 10;
  7. int stepsDuration = 100;
  8. // int arrayFromGoogleSheets[20] = {0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0};
  9. int arrayFromGoogleSheets[30] = {0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1};
  10.  
  11. int actuatorArrayStep[40];
  12.  
  13. int currentStep = 0;
  14. int actuatorState;
  15.  
  16. void SetArray()
  17. {
  18.     for(int i =0; i<actuators;i++)
  19.     {
  20.      actuatorArrayStep[i] = stepsCount*i; // 1
  21.     }
  22. }
  23. /* void TurnActuator(int actuator, int state)
  24. {
  25.     //digitalWrite(actuator, state);
  26. }
  27. */
  28. int main()
  29. {
  30.     SetArray();
  31. //  if(stepsDuration >= currentMillis-previousMillis)
  32. //  {
  33.    for(int k = 0; k<stepsCount; k++)
  34.    {
  35.         for(int i =0; i<actuators; i++)
  36.         {
  37.             int currentTempState = actuatorArrayStep[i] + currentStep;
  38.             actuatorState = arrayFromGoogleSheets[currentTempState];
  39.         //  TurnActuator(i, actuatorState);
  40.             if(actuatorState)
  41.                 cout << "motor: " << i <<"  true \n";
  42.             else
  43.                 cout << "motor: " << i <<" false \n";
  44.         }
  45.         currentStep++;
  46.    }
  47.   //}
  48. }
Advertisement
Add Comment
Please, Sign In to add comment