You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TactiloControllerPanda.ino 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. ///-------------------------------------------------------------------------------------------------
  2. ///
  3. /// \file TactiloControllerPanda.ino
  4. /// \brief Controlls the Tactilos on the Leonardos GPIOs, based on the messages from OpenVibes TactiloController Box Algorithm
  5. /// Hochladen mit der Arduino IDE
  6. /// \author Tobias Baumann (TH-Nürnberg).
  7. /// \version 1.0.
  8. /// \date Mon Mar 7 14:02:56 2022.
  9. ///
  10. ///-------------------------------------------------------------------------------------------------
  11. //define used GPIO pins
  12. #define TAC1 13 //PWM
  13. #define TAC2 11 //PWM
  14. #define TAC3 10 //PWM
  15. #define TAC4 9 //PWM
  16. #define TAC5 6 //PWM
  17. #define TAC6 5 //PWM
  18. //reserve
  19. #define TAC7 3 //PWM
  20. #define TAC8 2
  21. #define TAC9 1
  22. #define TAC10 0
  23. #define LED 13
  24. void setup()
  25. {
  26. //init serial
  27. Serial.begin(115200);
  28. //init GPIOs
  29. Serial.println("...init GPIOs");
  30. set_PinMode();
  31. set_AllLow();
  32. }
  33. void loop()
  34. {
  35. char SerialData;
  36. if(Serial.available() > 0)
  37. {
  38. SerialData = Serial.read();
  39. processSerialData(SerialData);
  40. }
  41. }
  42. void set_PinMode()
  43. {
  44. //set all pins to OUTPUT
  45. pinMode(TAC1, OUTPUT);
  46. pinMode(TAC2, OUTPUT);
  47. pinMode(TAC3, OUTPUT);
  48. pinMode(TAC4, OUTPUT);
  49. pinMode(TAC5, OUTPUT);
  50. pinMode(TAC6, OUTPUT);
  51. pinMode(TAC7, OUTPUT);
  52. pinMode(TAC8, OUTPUT);
  53. pinMode(TAC9, OUTPUT);
  54. pinMode(TAC10, OUTPUT);
  55. pinMode(LED, OUTPUT);
  56. }
  57. void set_AllLow()
  58. {
  59. //set all pins to LOW
  60. digitalWrite(TAC1, LOW);
  61. digitalWrite(TAC2, LOW);
  62. digitalWrite(TAC3, LOW);
  63. digitalWrite(TAC4, LOW);
  64. digitalWrite(TAC5, LOW);
  65. digitalWrite(TAC6, LOW);
  66. digitalWrite(TAC7, LOW);
  67. digitalWrite(TAC8, LOW);
  68. digitalWrite(TAC9, LOW);
  69. digitalWrite(TAC10, LOW);
  70. digitalWrite(LED, LOW);
  71. }
  72. void processSerialData(char SerialData)
  73. {
  74. switch(SerialData)
  75. {
  76. case '0':
  77. digitalWrite(TAC1, !digitalRead(TAC1));
  78. Serial.print("Tactilo 1: ");
  79. Serial.println(digitalRead(TAC1));
  80. break;
  81. case '1':
  82. digitalWrite(TAC2, !digitalRead(TAC2));
  83. Serial.print("Tactilo 2: ");
  84. Serial.println(digitalRead(TAC2));
  85. break;
  86. case '2':
  87. digitalWrite(TAC3, !digitalRead(TAC3));
  88. Serial.print("Tactilo 3: ");
  89. Serial.println(digitalRead(TAC3));
  90. break;
  91. case '3':
  92. digitalWrite(TAC4, !digitalRead(TAC4));
  93. Serial.print("Tactilo 4: ");
  94. Serial.println(digitalRead(TAC4));
  95. break;
  96. case '4':
  97. digitalWrite(TAC5, !digitalRead(TAC5));
  98. Serial.print("Tactilo 5: ");
  99. Serial.println(digitalRead(TAC5));
  100. break;
  101. case '5':
  102. digitalWrite(TAC6, !digitalRead(TAC6));
  103. Serial.print("Tactilo 6: ");
  104. Serial.println(digitalRead(TAC6));
  105. break;
  106. case '6':
  107. digitalWrite(TAC7, !digitalRead(TAC7));
  108. Serial.print("Tactilo 7: ");
  109. Serial.println(digitalRead(TAC7));
  110. break;
  111. case '7':
  112. digitalWrite(TAC8, !digitalRead(TAC8));
  113. Serial.print("Tactilo 8: ");
  114. Serial.println(digitalRead(TAC8));
  115. break;
  116. case '8':
  117. digitalWrite(TAC9, !digitalRead(TAC9));
  118. Serial.print("Tactilo 9: ");
  119. Serial.println(digitalRead(TAC9));
  120. break;
  121. case '9':
  122. digitalWrite(TAC10, !digitalRead(TAC10));
  123. Serial.print("Tactilo 10: ");
  124. Serial.println(digitalRead(TAC10));
  125. break;
  126. case 'b':
  127. if(digitalRead(LED) == LOW)
  128. {
  129. digitalWrite(LED, HIGH);
  130. Serial.println("...Begin Tactile Session");
  131. }
  132. break;
  133. case 'e':
  134. if(digitalRead(LED) == HIGH)
  135. {
  136. set_AllLow();
  137. Serial.println("...End Tactile Session");
  138. }
  139. break;
  140. default:
  141. break;
  142. }
  143. }