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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. void setup()
  24. {
  25. //init serial
  26. Serial.begin(115200);
  27. //init GPIOs
  28. Serial.println("...init GPIOs");
  29. set_PinMode();
  30. set_AllLow();
  31. }
  32. void loop()
  33. {
  34. char SerialData;
  35. if(Serial.available() > 0)
  36. {
  37. SerialData = Serial.read();
  38. processSerialData(SerialData);
  39. }
  40. }
  41. void set_PinMode()
  42. {
  43. pinMode(TAC1, OUTPUT);
  44. pinMode(TAC2, OUTPUT);
  45. pinMode(TAC3, OUTPUT);
  46. pinMode(TAC4, OUTPUT);
  47. pinMode(TAC5, OUTPUT);
  48. pinMode(TAC6, OUTPUT);
  49. //reserve
  50. pinMode(TAC7, OUTPUT);
  51. pinMode(TAC8, OUTPUT);
  52. pinMode(TAC9, OUTPUT);
  53. pinMode(TAC10, OUTPUT);
  54. }
  55. void set_AllLow()
  56. {
  57. digitalWrite(TAC1, LOW);
  58. digitalWrite(TAC2, LOW);
  59. digitalWrite(TAC3, LOW);
  60. digitalWrite(TAC4, LOW);
  61. digitalWrite(TAC5, LOW);
  62. digitalWrite(TAC6, LOW);
  63. //reserve
  64. digitalWrite(TAC7, LOW);
  65. digitalWrite(TAC8, LOW);
  66. digitalWrite(TAC9, LOW);
  67. digitalWrite(TAC10, LOW);
  68. }
  69. void processSerialData(char SerialData)
  70. {
  71. switch(SerialData)
  72. {
  73. case '0':
  74. digitalWrite(TAC1, !digitalRead(TAC1));
  75. //Serial.print("Tactilo 1: ");
  76. //Serial.println(digitalRead(TAC1));
  77. break;
  78. case '1':
  79. digitalWrite(TAC2, !digitalRead(TAC2));
  80. //Serial.print("Tactilo 2: ");
  81. //Serial.println(digitalRead(TAC2));
  82. break;
  83. case '2':
  84. digitalWrite(TAC3, !digitalRead(TAC3));
  85. //Serial.print("Tactilo 3: ");
  86. //Serial.println(digitalRead(TAC3));
  87. break;
  88. case '3':
  89. digitalWrite(TAC4, !digitalRead(TAC4));
  90. //Serial.print("Tactilo 4: ");
  91. //Serial.println(digitalRead(TAC4));
  92. break;
  93. case '4':
  94. digitalWrite(TAC5, !digitalRead(TAC5));
  95. //Serial.print("Tactilo 5: ");
  96. //Serial.println(digitalRead(TAC5));
  97. break;
  98. case '5':
  99. digitalWrite(TAC6, !digitalRead(TAC6));
  100. //Serial.print("Tactilo 6: ");
  101. //Serial.println(digitalRead(TAC6));
  102. break;
  103. case '6':
  104. digitalWrite(TAC7, !digitalRead(TAC7));
  105. //Serial.print("Tactilo 7: ");
  106. //Serial.println(digitalRead(TAC7));
  107. break;
  108. case '7':
  109. digitalWrite(TAC8, !digitalRead(TAC8));
  110. //Serial.print("Tactilo 8: ");
  111. //Serial.println(digitalRead(TAC8));
  112. break;
  113. case '8':
  114. digitalWrite(TAC9, !digitalRead(TAC9));
  115. //Serial.print("Tactilo 9: ");
  116. //Serial.println(digitalRead(TAC9));
  117. break;
  118. case '9':
  119. digitalWrite(TAC10, !digitalRead(TAC10));
  120. //Serial.print("Tactilo 10: ");
  121. //Serial.println(digitalRead(TAC10));
  122. break;
  123. case 'b':
  124. Serial.println("...Begin Tactile Session");
  125. break;
  126. case 'e':
  127. set_AllLow();
  128. Serial.println("...End Tactile Session");
  129. break;
  130. default:
  131. break;
  132. }
  133. }