Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int actuators = 6; // 3
- int stepsCount = 10; // Tova ne ni trqbva tuk
- int stepsDuration = 100;
- string input = "101000001110100000111010000011101000001110100000111010000011";
- int inputConvertedArray[60]; // Int array for the main
- int actuatorArrayStep[40];
- int currentStep = 0;
- int actuatorState;
- void stringToInt(string inputStr) // String to int array
- {
- int inputStringSize = inputStr.length();
- cout << "input string size " << inputStringSize << endl;
- for(int i =0; i<inputStringSize; i++)
- {
- inputConvertedArray[i] = inputStr.at(i) - 48;
- }
- // Print for test
- cout << endl;
- for(int i =0; i<inputStringSize;i++)
- {
- cout << inputConvertedArray[i];
- }
- cout << endl;
- }
- void SetArray()
- {
- for(int i =0; i<actuators;i++)
- {
- actuatorArrayStep[i] = stepsCount*i; // 1
- }
- }
- /* void TurnActuator(int actuator, int state)
- {
- //digitalWrite(actuator, state);
- }
- */
- int main()
- {
- SetArray();
- stringToInt(input);
- for(int k = 0; k<stepsCount; k++)
- {
- cout << "LOOP CYCLE: " << k << endl;
- for(int i =0; i<actuators; i++)
- {
- int currentTempState = actuatorArrayStep[i] + currentStep;
- actuatorState = inputConvertedArray[currentTempState];
- // TurnActuator(i, actuatorState);
- if(actuatorState == 1)
- cout << "motor: " << i <<" true \n";
- else
- cout << "motor: " << i <<" false \n";
- }
- currentStep++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement