Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. #include<DAQlib.h>
  6. #include<Windows.h>
  7.  
  8. #define TRUE 1
  9. #define False 0
  10.  
  11. #define RUN_SWITCH 1
  12. #define RESET_SWITCH 0
  13. #define ONE_SECOND 1000
  14. #define NUM_DISPLAYS 8
  15. #define TURNOFF 0
  16.  
  17. //Function Prototypes
  18.  
  19. void writeNumber(int number);
  20. void writeDigit(int digit, int position);
  21. void runCounter(int startVal, int endVal);
  22.  
  23.  
  24. int main(void) {
  25. int setupNUM;
  26. int startVAL;
  27. int endVAL;
  28.  
  29. printf("Please enter 4 for the simulator: ");
  30. scanf("%d", &setupNUM);
  31.  
  32. if (setupDAQ(setupNUM) == TRUE) {
  33. while (continueSuperLoop() == TRUE) {
  34. printf("Please enter a starting value: ");
  35. scanf("%d", &startVAL);
  36. printf("Please enter an ending value: ");
  37. scanf("%d", &endVAL);
  38.  
  39. while (digitalRead(RESET_SWITCH) || digitalRead(RUN_SWITCH) == TRUE) {
  40. printf("Both switches must be set to off to proceed.");
  41. }
  42. writeNumber(startVAL);
  43. runCounter(startVAL, endVAL);
  44.  
  45.  
  46. }
  47. }
  48. }
  49.  
  50. void runCounter(int startVal, int endVal) {
  51. while (continueSuperLoop() == TRUE) {
  52. while (digitalRead(RESET_SWITCH) && digitalRead(RUN_SWITCH) == FALSE) {
  53. for (startVal; startVal <= endVal; startVal++) {
  54. writeNumber(startVal);
  55. Sleep(ONE_SECOND);
  56. }
  57. }
  58. }
  59. }
  60.  
  61. void writeNumber(int number) {
  62. int pos = 0;
  63. int digit;
  64.  
  65. do {
  66. digit = number % 10;
  67. number = number / 10;
  68. writeDigit(digit, pos);
  69. } while (pos < NUM_DISPLAYS && number != 0);
  70. while (pos < NUM_DISPLAYS) {
  71. displayWrite(TURNOFF, pos);
  72. pos++;
  73. }
  74. }
  75.  
  76. void writeDigit(int digit, int position) {
  77. static int digitsTable[10] = { 252,96,218,242,102,182,190,224,254,256 };
  78.  
  79. displayWrite(digitsTable[digit], position);
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement