daily pastebin goal
46%
SHARE
TWEET

Test_trame_dmx

TsarOty Mar 26th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <DmxSimple.h>
  2.  
  3. int index_val1; // Valeur correspondant a l'adresse dmx du bidule
  4. int index_val2; // Valeur des sliders
  5. int index_val3;
  6. int index_val4;
  7. int index_val5;
  8. int index_val6;
  9. int index_val7;
  10. int index_val8;
  11. int index_val9;
  12. int index_val10;
  13. int index_val11;
  14. int index_val12;
  15. int index_val13;
  16. int index_val14;
  17.  
  18.  
  19. String Str_message; // Trame
  20. String Str_chaine1;
  21. String Str_chaine2;
  22. String Str_chaine3;
  23. String Str_chaine4;
  24. String Str_chaine5;
  25. String Str_chaine6;
  26. String Str_chaine7;
  27. String Str_chaine8;
  28. String Str_chaine9;
  29. String Str_chaine10;
  30. String Str_chaine11;
  31. String Str_chaine12;
  32. String Str_chaine13;
  33.  
  34.  
  35.  
  36. int val_1; // Valeur correspondant a l'adresse dmx du bidule
  37. int val_2; // Valeur des sliders
  38. int val_3;
  39. int val_4;
  40. int val_5;
  41. int val_6;
  42. int val_7;
  43. int val_8;
  44. int val_9;
  45. int val_10;
  46. int val_11;
  47. int val_12;
  48. int val_13;
  49.  
  50. int index;
  51. int val;
  52.  
  53. int val_slide[32];
  54. int val_adress;
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. void setup() {
  64.   Serial.begin(9600);
  65.   DmxSimple.maxChannel(32);
  66.   DmxSimple.usePin(3);
  67.  
  68.  
  69. }
  70.  
  71. void loop() {
  72.   lire_message();
  73.   decode_message();
  74.   delay(250);
  75.   ecrire_message();
  76.   trame();
  77.   delay(250);
  78.  
  79.    
  80.  
  81.  
  82.  
  83.  
  84.  
  85. }
  86. void trame() {
  87.   if ( val_adress == 1){
  88.      for (int i=0; i<=6;i++){
  89.      DmxSimple.write(i+1,val_slide[i]);
  90.      }
  91.      }
  92. //$#1#10#20#30#40#50#60#
  93.    if ( val_adress == 7){
  94.      for (int i=7; i<=13;i++){
  95.      DmxSimple.write(i+1,val_slide[i]);
  96.      }
  97.      }
  98.   /*for (int i = 0; i <= 6; i++) {
  99.     DmxSimple.write(i + 1, val_slide[i]);
  100.   }*/
  101. }
  102. void decode_message()
  103. {
  104.   if (Str_message.startsWith("$"))
  105.   {
  106.     index_val1 = Str_message.indexOf('#');
  107.     index_val2 = Str_message.indexOf('#', index_val1 + 1);
  108.     index_val3 = Str_message.indexOf('#', index_val2 + 1);
  109.     index_val4 = Str_message.indexOf('#', index_val3 + 1);
  110.     index_val5 = Str_message.indexOf('#', index_val4 + 1);
  111.     index_val6 = Str_message.indexOf('#', index_val5 + 1);
  112.     index_val7 = Str_message.indexOf('#', index_val6 + 1);
  113.     index_val8 = Str_message.indexOf('#', index_val1 + 1);
  114.     index_val9 = Str_message.indexOf('#', index_val2 + 1);
  115.     index_val10 = Str_message.indexOf('#', index_val3 + 1);
  116.     index_val11 = Str_message.indexOf('#', index_val4 + 1);
  117.     index_val12 = Str_message.indexOf('#', index_val5 + 1);
  118.     index_val13 = Str_message.indexOf('#', index_val6 + 1);
  119.  
  120.  
  121.     Str_chaine1 = Str_message.substring(index_val1 + 1);
  122.     val_adress = Str_chaine1.toInt();
  123.     Str_chaine2 = Str_message.substring(index_val2 + 1);
  124.     val_slide[0] = Str_chaine2.toInt();
  125.     Str_chaine3 = Str_message.substring(index_val3 + 1);
  126.     val_slide[1] = Str_chaine3.toInt();
  127.     Str_chaine4 = Str_message.substring(index_val4 + 1);
  128.     val_slide[2] = Str_chaine4.toInt();
  129.     Str_chaine5 = Str_message.substring(index_val5 + 1);
  130.     val_slide[3] = Str_chaine5.toInt();
  131.     Str_chaine6 = Str_message.substring(index_val6 + 1);
  132.     val_slide[4] = Str_chaine6.toInt();
  133.     Str_chaine7 = Str_message.substring(index_val7 + 1);
  134.     val_slide[5] = Str_chaine7.toInt();
  135.     Str_chaine8 = Str_message.substring(index_val8 + 1);
  136.     val_slide[6] = Str_chaine8.toInt();
  137.     Str_chaine9 = Str_message.substring(index_val9 + 1);
  138.     val_slide[7] = Str_chaine9.toInt();
  139.     Str_chaine10 = Str_message.substring(index_val10 + 1);
  140.     val_slide[8] = Str_chaine10.toInt();
  141.     Str_chaine11 = Str_message.substring(index_val11 + 1);
  142.     val_slide[9] = Str_chaine11.toInt();
  143.     Str_chaine12 = Str_message.substring(index_val12 + 1);
  144.     val_slide[10] = Str_chaine12.toInt();
  145.     Str_chaine13 = Str_message.substring(index_val13 + 1);
  146.     val_slide[11] = Str_chaine13.toInt();
  147.  
  148.  
  149.   }
  150. }
  151. void ecrire_message() {
  152.   for (int i = 0; i <= 13; i++) {
  153.     Serial.println(val_slide[i]);
  154.   }
  155. }
  156.  
  157. void lire_message()
  158. {
  159.   Str_message = "";
  160.   while (Serial.available() != 0)
  161.   {
  162.     Str_message = String(Str_message + char(Serial.read()));
  163.     delay(1);
  164.   }
  165.   Serial.println(Str_message);
  166. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top