Safiron

Arduino

Feb 19th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. #include <SPI.h> // needed for Arduino versions later than 0018
  2. #include <Ethernet.h>
  3. #include <ATEM.h>
  4.  
  5. byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x66, 0x07 }; // ARDUINO MAC
  6. IPAddress ip(192, 168, 5, 25); // ARDUINO IP
  7.  
  8. int button1 = 2;
  9. int button2 = 4;
  10. int button3 = 6;
  11. int button4 = 8;
  12. int button5 = 10;
  13. int button5 = 12;
  14. int tally1 = 3;
  15. int tally2 = 5;
  16. int tally3 = 7;
  17. int tally4 = 9;
  18. int tally5 = 11;
  19. int tally6 = 13;
  20.  
  21. bool lastButton = LOW;
  22. bool ledOn = false;
  23. bool currentButton = LOW;
  24. bool lastState = false;
  25.  
  26. ATEM AtemSwitcher(IPAddress(192, 168, 5, 5), 56417); // ATEM SWITCHER IP and RANDOM PORT
  27.  
  28.  
  29. bool debounce(bool last,int pinNumber)
  30. {
  31. bool current = digitalRead(pinNumber);
  32. if (last != current)
  33. {
  34. delay(20);
  35. current = digitalRead(pinNumber);
  36. }
  37. return current;
  38. }
  39.  
  40. void setup()
  41. {
  42. pinMode(tally1, OUTPUT);
  43. pinMode(tally2, OUTPUT);
  44. pinMode(tally3, OUTPUT);
  45. pinMode(tally4, OUTPUT);
  46. pinMode(tally5, OUTPUT);
  47. pinMode(tally6, OUTPUT);
  48. pinMode(button1, INPUT);
  49. pinMode(button2, INPUT);
  50. pinMode(button3, INPUT);
  51. pinMode(button4, INPUT);
  52. pinMode(button5, INPUT);
  53. pinMode(button6, INPUT);
  54.  
  55.  
  56. Ethernet.begin(mac,ip);
  57. Serial.begin(9600);
  58.  
  59.  
  60. // Initialize a connection to the switcher:
  61. AtemSwitcher.serialOutput(true);
  62. AtemSwitcher.connect();
  63. }
  64.  
  65.  
  66. void loop()
  67. {
  68. // Check for packets, respond to them etc. Keeping the connection alive!
  69. AtemSwitcher.runLoop();
  70. digitalWrite(progTally1Pin, AtemSwitcher.getProgramTally(5));
  71.  
  72. if (!AtemSwitcher.getProgramTally(5))
  73. {
  74. digitalWrite(tally1, HIGH);
  75. //Serial.println("ON");
  76. }
  77. else
  78. {
  79. digitalWrite(tally1, LOW);
  80. //Serial.println("OFF");
  81. }
  82.  
  83. // delay(1000);
  84. // else
  85. // {
  86. // //digitalWrite(progTally1Pin, HIGH);
  87. // //Serial.println("OFF");
  88. // }
  89. //
  90. // currentButton = debounce(lastButton, cutPin);
  91. // if (lastButton == LOW && currentButton == HIGH )
  92. // {
  93. // Serial.println("Cut");
  94. // AtemSwitcher.doCut();
  95. // }
  96. // lastButton = currentButton;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment