Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. // RTI_RGB = 0x40, RTI_PAL = 0x45, RTI_NTSC = 0x4C, RTI_OFF = 0x46
  2. // brightness levels 0x20, 0x61, 0x62, 0x23, 0x64, 0x25, 0x26, 0x67, 0x68, 0x29, 0x2A, 0x2C, 0x6B, 0x6D, 0x6E, 0x2F
  3.  
  4. #define R_PIN 3
  5. #define AUTO_CLOSE_PIN 5
  6. #define SERIAL_SWITCH_PIN 4
  7.  
  8. bool zpatecka_on = false;
  9.  
  10. int x=0;
  11.  
  12. void setup()
  13. {
  14. Serial.begin(2400);
  15.  
  16. //nastavi pin na 1
  17. pinMode(R_PIN, INPUT_PULLUP);
  18. attachInterrupt(digitalPinToInterrupt(R_PIN), preruseni, CHANGE);
  19. }
  20.  
  21. void loop()
  22. {
  23.  
  24. if (zpatecka_on == true){
  25. zpateckaOn();
  26. }
  27. else
  28. {
  29. zpateckaOff();
  30. }
  31.  
  32. }
  33.  
  34. void preruseni()
  35. {
  36. //if (zpatecka_on == false){
  37.  
  38. if (digitalRead(R_PIN) == HIGH)
  39. {
  40. zpatecka_on = true;
  41. }
  42. else
  43. {
  44. zpatecka_on=false;
  45.  
  46. }
  47. }
  48.  
  49. void zpateckaOn()
  50. {
  51. rtiWrite(0x4C);
  52. rtiWrite(0x6B);
  53. rtiWrite(0x83);
  54. digitalWrite(SERIAL_SWITCH_PIN, HIGH);
  55. if (digitalRead(AUTO_CLOSE_PIN) == LOW){
  56. x==1;
  57. }
  58. }
  59.  
  60. void zpateckaOff()
  61. {
  62. // Kod po vyrazeni zpatecky
  63. if (digitalRead(AUTO_CLOSE_PIN) == HIGH)
  64. {
  65. rtiWrite(0x46);
  66. rtiWrite(0x6B);
  67. rtiWrite(0x83);
  68. digitalWrite(SERIAL_SWITCH_PIN, LOW);
  69. }
  70. else if (digitalRead(AUTO_CLOSE_PIN) == LOW and x==1)
  71. {
  72. rtiWrite(0x40);
  73. rtiWrite(0x6B);
  74. rtiWrite(0x83);
  75. digitalWrite(SERIAL_SWITCH_PIN, LOW);
  76. x==0;
  77. }
  78. }
  79.  
  80. void rtiWrite(char byte) {
  81. Serial.print(byte);
  82. delay(100);
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement