Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////////
- // Time Study Arduino Assistant//
- // By Nicky Fingerle //
- /////////////////////////////////
- double stopStartTimes [4][5] = { 0 };
- /*
- machine | 1 | 2 | 3 | 4 | 5 |
- lastStop | - | - | - | - | - |
- stopTime | - | - | - | - | - |
- restartTime | - | - | - | - | - |
- */
- double downTimeAndElapsedTime [2][5] = { 0 };
- /*
- machine | 1 | 2 | 3 | 4 | 5 |
- elapsed | - | - | - | - | - |
- downtime | - | - | - | - | - |
- */
- double logSheet [1000][4];
- bool isButtonPressed;
- bool isStopped [5] = { 0 };
- bool initialized [5] = { 0 };
- int universalCount = 0;
- int pullDown;
- void setup()
- {
- pinMode( 1, OUTPUT );
- pinMode( 2, OUTPUT );
- pinMode( 3, OUTPUT );
- pinMode( 4, OUTPUT );
- pinMode( 5, OUTPUT );
- pinMode( 6, INPUT );
- pinMode( 7, INPUT );
- pinMode( 8, INPUT );
- pinMode( 9, INPUT );
- pinMode( 10, INPUT );
- }
- void loop()
- {
- for ( int i = 1; i < 5; ++i )
- {
- digitalWrite( i, HIGH );
- pullDown = i + 5; //This 5 needs to be increased by 1 for any additional machine
- isButtonPressed = digitalRead( pullDown );
- if ( isButtonPressed == HIGH )
- {
- if ( isStopped [i] == 0 )
- {
- isStopped [i] = 1;
- stopStartTimes [1][i] = millis();
- if ( initialized [i] = 0 )
- {
- downTimeAndElapsedTime [0][i] = 0;
- initialized [i] = 1;
- }
- else
- {
- downTimeAndElapsedTime [0][i] = (round((stopStartTimes [1][i] - stopStartTimes [0][i]) / 100))/10;
- }
- stopStartTimes [0][i] = stopStartTimes [1][i];
- }
- else if ( isStopped [i] == 1 )
- {
- isStopped [i] = 0;
- stopStartTimes [2][i] = millis();
- downTimeAndElapsedTime [1][i] = (round((stopStartTimes [2][i] - stopStartTimes [1][i]) / 100))/10;
- logSheet [universalCount][0] = universalCount;
- logSheet [universalCount][1] = 1;
- logSheet [universalCount][2] = downTimeAndElapsedTime [1][0];
- logSheet [universalCount][3] = downTimeAndElapsedTime [0][0];
- //This is where the logging txt sheet and the LCD library come in.
- universalCount = universalCount + 1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement