Advertisement
MarjorieM3

MaxCtrl 1 Oficial

Jun 4th, 2021
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.58 KB | None | 0 0
  1. /*
  2.   Código feito através de modificações de códigos pertencentes ao Gustavo Silveira (http://www.musiconerd.com)
  3.   e código encontrado no GitHub (https://github.com/romix123/Seeeduino_XIAO_MIDI_drumpad/blob/main/XiaoDrum/XiaoDrum.ino).
  4.   Os códigos possuem parte autoral e alterações dos códigos mencionados feitas por: Marjorie Macário Maximiano.
  5.   Feito para funcionar em arduino com ATmega 328 (Uno, Mega, Nano,...)
  6.   Fatec - Tatuí
  7.   Produção Fonográfica
  8.   Trabalho de Graduação 2021.1
  9.   MaxControl: Desenvolvimento de controlador MIDI de baixo custo.
  10.   //Membros do Grupo:
  11.   -Augusto Cesar Mendes Gomes;
  12.   -Guilherme Luis Lima Furlan;
  13.   -Leonardo Alan Kirchner;
  14.   -Marjorie Macário Maximiano;
  15.   -Rayla Aparecida Manoel.
  16.   //Orientador:
  17.   -Lucas Correia Meneguette.
  18.   //Coorientador:
  19.   -Otávio dos Santos Gaijuts.
  20. */
  21. #define ATMEGA328 1//* coloque aqui o uC que você está usando, como nas linhas acima seguido por "1", como "ATMEGA328 1", "DEBUG 1", etc.
  22.  
  23. ////////////////////////////////////////////////////////////////////////////////////////M A X C T R L 1////////////////////////////////////////////////////////////////////////////////////////
  24. /////////////////////////////////////////////
  25. // BIBLIOTECAS
  26. // -- Define a biblioteca MIDI -- //
  27.  
  28. // se estiver usando com ATmega328 - Uno, Mega, Nano ...
  29. #include <MIDI.h>
  30. MIDI_CREATE_DEFAULT_INSTANCE();
  31. ////////////////////////////////////////////////////////////////////////////////////////////BOTOES/////////////////////////////////////////////////////////////////////////////////////////////
  32. const int N_BUTTONS = 16; //número total de botões usados.
  33. const int BUTTON_ARDUINO_PIN[N_BUTTONS] = {4, 5, 6, 7, 8, 9, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25}; //pinagem de todos os botões.
  34. ////Botões DAW = 4,5, 6, 7, 8, 9, 14;
  35. ////Botão Joystick = 16;
  36. ////Botões Encoders = 17, 18, 19, 22;
  37. ///Pedal = 23;
  38. ////Botões Transpose = 24, 25;
  39.  
  40. int buttonCState [N_BUTTONS] = {0};
  41. int buttonPState [N_BUTTONS] = {0};
  42. //debounce
  43. unsigned long lastDebounceTime[N_BUTTONS] = {0};
  44. unsigned long debounceDelay = 5;
  45.  
  46. ///////////////////////////////////////////////////////////////////////////////////////////PIEZOS//////////////////////////////////////////////////////////////////////////////////////////////
  47. const int N_PIEZO = 13;
  48. const int PIEZO_ARDUINO_PIN[N_PIEZO] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12};
  49. boolean piezo = false;
  50.  
  51. ///////////////////////////////////////////////////////////////////////////////////////LEDS TRANSPOSE//////////////////////////////////////////////////////////////////////////////////////////
  52.  
  53. const int N_LEDS = 6;
  54. const int LEDS_ARDUINO_PIN [N_LEDS] = {26, 27, 28, 29, 30, 31};
  55. //int pinoR1 = 26;
  56. //int pinoG1 = 27;
  57. //int pinoB1 = 28;
  58. //int pinoR2 = 29;
  59. //int pinoG2 = 30;
  60. //int pinoB2 = 31;
  61.  
  62. #define COMMOM_ANODE // Caso esteja usando o LED RGB com catodo comum, comente essa linha.
  63. bool estadoLed = 0;
  64.  
  65. //////////////////////////////////////////////////////////////////////////////////////////JOYSTICK/////////////////////////////////////////////////////////////////////////////////////////////
  66. const int N_POTS = 2; //* total numbers of pots (slide & rotary)
  67. const int POT_ARDUINO_PIN[N_POTS] = {A13, A14}; //* pins of each pot connected straight to the Arduino
  68.  
  69. int potCState[N_POTS] = {0}; // Current state of the pot
  70. int potPState[N_POTS] = {0}; // Previous state of the pot
  71. int potVar = 0; // Difference between the current and previous state of the pot
  72.  
  73. int midiCState[N_POTS] = {0}; // Current state of the midi value
  74. int midiPState[N_POTS] = {0}; // Previous state of the midi value
  75.  
  76. const int TIMEOUT = 1000; //* Amount of time the potentiometer will be read after it exceeds the varThreshold
  77. const int varThreshold = 5; //* Threshold for the potentiometer signal variation
  78. boolean potMoving = true; // If the potentiometer is moving
  79. unsigned long PTime[N_POTS] = {0}; // Previously stored time
  80. unsigned long timer[N_POTS] = {0}; // Stores the time that has elapsed since the timer was reset
  81.  
  82. /////////////////////////////////
  83. // MIDI IN
  84. byte midiCh = 1;
  85. byte note = 60;
  86. byte cc = 1;
  87. byte ENCODER_MIDI_CH = 0;
  88.  
  89. ////////////////////////////////////////////////////////////////////////////////////////PITCH BEND/////////////////////////////////////////////////////////////////////////////////////////////
  90. //multiMap(int value, int fromMap[], int fromMapSize, int toMap[], int toMapSize)
  91. int PBVal = 0;
  92. int PBFromMap [] {0, 532, 1023};
  93. int PBToMpas [] {0, 16383};
  94. byte PBFromMapSize = 14;
  95. byte PBToMapSize = 13;
  96.  
  97. byte shiftVal = 19;
  98.  
  99. ////////////////////////////////////////////////////////////////////////////////////////ENCODERS/////////////////////////////////////////////////////////////////////////////////////////////
  100. #include <Encoder.h>
  101. const byte N_ENCODERS = 4; //* número de encoders
  102. const byte N_ENCODER_PINS = N_ENCODERS * 2; // número de pinos usados pelos codificadores
  103. const byte N_ENCODER_MIDI_CHANNELS = 16; // número de ENCODER_MIDI_CHs
  104.  
  105. byte ENCODER_CC_N[N_ENCODERS] = {16, 17, 18, 19}; //* Adicione o CC NUMBER de cada encoder que você deseja
  106.  
  107. Encoder encoder[N_ENCODERS] = {{2, 3}, {10, 11}, {12, 13} , {20, 21}}; //* os dois pinos de cada encoder - Use pinos com interrupts!
  108.  
  109. byte encoderMinVal = 0; //* valor mínimo do encoder
  110. byte encoderMaxVal = 127; //* vamor máximo do encoder
  111.  
  112. byte preset[N_ENCODER_MIDI_CHANNELS][N_ENCODERS] = { //* armazena presets para o seu encoder
  113.   //  {64, 64}, // ch 1
  114.   //  {64, 64}, // ch 2
  115.   //  {64, 64}, // ch 3
  116.   //  {64, 64}, // ch 4
  117.   //  {64, 64}, // ch 5
  118.   //  {64, 64}, // ch 6
  119.   //  {64, 64}, // ch 7
  120.   //  {64, 64}, // ch 8
  121.   //  {64, 64}, // ch 9
  122.   //  {64, 64}, // ch 10
  123.   //  {64, 64}, // ch 11
  124.   //  {64, 64}, // ch 12
  125.   //  {64, 64}, // ch 13
  126.   //  {64, 64}, // ch 14
  127.   //  {64, 64}, // ch 15
  128.   //  {64, 64}  // ch 16
  129. };
  130.  
  131. byte lastEncoderValue[N_ENCODER_MIDI_CHANNELS][N_ENCODERS] = {127};
  132. byte encoderValue[N_ENCODER_MIDI_CHANNELS][N_ENCODERS] = {127};
  133.  
  134. // para os canais dos encoders - Usado para bancos diferentes
  135.  
  136. byte lastEncoderChannel = 0;
  137.  
  138. unsigned long encPTime[N_ENCODERS] = {0};
  139. unsigned long encTimer[N_ENCODERS] = {0};
  140. boolean encMoving[N_ENCODERS] = {false};
  141. boolean encMoved[N_ENCODERS] = {false};
  142. byte encTIMEOUT = 50;
  143. byte encoder_n;
  144. byte encTempVal = 0;
  145.  
  146. void setup () {
  147.  
  148.   Serial.begin (115200);
  149.   delay(1000);
  150.   for (int i = 0; i < N_LEDS; i++) {
  151.     pinMode (LEDS_ARDUINO_PIN[i], OUTPUT);
  152.   }
  153.   for (int i = 0; i < N_BUTTONS; i++) {
  154.     pinMode (BUTTON_ARDUINO_PIN[i], INPUT_PULLUP);
  155.   }
  156.  
  157.   for (int i = 0; i < N_ENCODERS; i++) {
  158.     encoder [i].write(preset[0][i]);
  159.   }
  160.   for (int z = 0; z < N_ENCODER_MIDI_CHANNELS; z++) {
  161.     for (int i = 0; i < N_ENCODERS; i++) {
  162.       lastEncoderValue[z][i] = preset[z][i];
  163.     }
  164.   }
  165.  
  166.  
  167.   ENCODER_MIDI_CH++;
  168.  
  169.   /////////////////////////////////////////////
  170.   // Midi in
  171.   MIDI.turnThruOff();
  172.   //  MIDI.setHandleControlChange(handleControlChange);
  173.   //  MIDI.setHandleNoteOn(handleNoteOn);
  174.   //  MIDI.setHandleNoteOff(handleNoteOff);
  175. }
  176. void loop () {
  177.   MIDI.read();
  178.   encoders();
  179.   isEncoderMoving();
  180.   buttons();
  181.   leds();
  182.   joystick();
  183.   piezos();
  184. }
  185.  
  186. //////////////////////////////////////
  187. //////// BOTÕES
  188. void buttons() {
  189.   for (int i = 0; i < N_BUTTONS; i++) {
  190.     buttonCState [i] = digitalRead(BUTTON_ARDUINO_PIN[i]);
  191.     if ((millis() - lastDebounceTime[i]) > debounceDelay) {
  192.       if (buttonPState [i] != buttonCState [i]) {
  193.         lastDebounceTime [i] = millis();
  194.         if (buttonCState [14] == LOW) {
  195.           //decrease midi transpose
  196.           note -= 12; // TRANSPOSE DOWN
  197.           if (note < 24) {
  198.             note = 24;
  199.           }
  200.  
  201.         }        else if (buttonCState [15] == LOW) {
  202.           //increase midi transpose
  203.           note += 12; //TRANSPOSE UP
  204.           if (note > 96) {
  205.             note = 96;
  206.           }
  207.         }
  208.        if (buttonCState[i] == LOW) {
  209.  
  210.  
  211.         }
  212.         ///////////////////////////////////
  213.         ///////BOTÕES DAW - JOYSTICK - ENCODERS - PEDAL (ADICIONAR OS BOTÕES DOS ENCODERS COM MUDANÇA DE BANCOS)
  214.         if (buttonCState [0] == LOW) {
  215.           MIDI.sendControlChange (20, 127, 1); //Botão DAW 1
  216.         }
  217.  
  218.         if (buttonCState [1] == LOW) {
  219.           MIDI.sendControlChange (21, 127, 1); //Botão DAW 2
  220.         }
  221.  
  222.         if (buttonCState [2] == LOW) {
  223.           MIDI.sendControlChange (22, 127, 1); //Botão DAW 3
  224.         }
  225.  
  226.         if (buttonCState [3] == LOW) {
  227.           MIDI.sendControlChange (23, 127, 1); //Botão DAW 4
  228.         }
  229.  
  230.         if (buttonCState [4] == LOW) {
  231.           MIDI.sendControlChange (24, 127, 1); //Botão DAW 5
  232.         }
  233.  
  234.         if (buttonCState [5] == LOW) {
  235.           MIDI.sendControlChange (25, 127, 1); //Botão DAW 6
  236.         }
  237.  
  238.         if (buttonCState [6] == LOW) {
  239.           MIDI.sendControlChange (26, 127, 1); //Botão DAW 7
  240.         }
  241.  
  242.         if (buttonCState [7] == LOW) {
  243.           MIDI.sendControlChange (27, 127, 1); //Botão DAW 8
  244.         }
  245.  
  246.         if (buttonCState [8] == LOW) {
  247.           MIDI.sendControlChange (28, 127, 1); //Botão Joystick
  248.         }
  249.  
  250.         if (buttonCState [9] == LOW) {
  251.           MIDI.sendControlChange (29, 127, 1); //Botão Encoder 1
  252.         }
  253.  
  254.         if (buttonCState [10] == LOW) {
  255.           MIDI.sendControlChange (30, 127, 1); //Botão Encoder 2
  256.         }
  257.  
  258.         if (buttonCState [11] == LOW) {
  259.           MIDI.sendControlChange (31, 127, 1); //Botão Encoder 3
  260.         }
  261.  
  262.         if (buttonCState [12] == LOW) {
  263.           MIDI.sendControlChange (85, 127, 1); //Botão Encoder 4
  264.         }
  265.  
  266.         if (buttonCState [13] == HIGH) {
  267.           MIDI.sendControlChange (64, 127, 1); //Pedal
  268.         }
  269.  
  270.       }
  271.       buttonPState [i] = buttonCState [i];
  272.     }
  273.   }
  274. }
  275.  
  276.  
  277. ///////////////////////////
  278. ///////LEDS INDICADORES DE TRANSPOSE
  279. void leds() {
  280.   for (int i = 0; i < N_LEDS; i++) {
  281.     if (note == 24) {
  282.       digitalWrite (LEDS_ARDUINO_PIN[0], HIGH);
  283.     }
  284.     if (note != 24) {
  285.       digitalWrite (LEDS_ARDUINO_PIN[0], LOW);
  286.     }
  287.     if (note == 36) {
  288.       digitalWrite (LEDS_ARDUINO_PIN[1], HIGH);
  289.     }
  290.  
  291.     if (note != 36) {
  292.       digitalWrite (LEDS_ARDUINO_PIN[1], LOW);
  293.     }
  294.     if (note == 48) {
  295.       digitalWrite (LEDS_ARDUINO_PIN[2], HIGH);
  296.     }
  297.     if (note != 48) {
  298.       digitalWrite (LEDS_ARDUINO_PIN[2], LOW);
  299.     }
  300.     if (note == 72) {
  301.       digitalWrite (LEDS_ARDUINO_PIN[3], HIGH);
  302.     }
  303.     if (note != 72) {
  304.       digitalWrite (LEDS_ARDUINO_PIN[3], LOW);
  305.     }
  306.     if (note == 84) {
  307.       digitalWrite (LEDS_ARDUINO_PIN[4], HIGH);
  308.     }
  309.  
  310.     if (note != 84) {
  311.       digitalWrite (LEDS_ARDUINO_PIN[4], LOW);
  312.     }
  313.     if (note == 96) {
  314.       digitalWrite (LEDS_ARDUINO_PIN[5], HIGH);
  315.     }
  316.     if (note != 96) {
  317.       digitalWrite (LEDS_ARDUINO_PIN[5], LOW);
  318.     }
  319.  
  320.   }
  321. }
  322.  
  323. /////////////////////////////
  324. ////////////JOYSTICK
  325. void joystick() {
  326.  
  327.  
  328.   for (int i = 0; i < N_POTS; i++) { // Loops through all the potentiometers
  329.  
  330.     potCState[i] = analogRead(POT_ARDUINO_PIN[i]); // reads the pins from arduino
  331.  
  332.     midiCState[i] = map(potCState[i], 0, 1023, 0, 127); // Maps the reading of the potCState to a value usable in midi
  333.  
  334.     potVar = abs(potCState[i] - potPState[i]); // Calculates the absolute value between the difference between the current and previous state of the pot
  335.  
  336.     if (potVar > varThreshold) { // Opens the gate if the potentiometer variation is greater than the threshold
  337.       PTime[i] = millis(); // Stores the previous time
  338.     }
  339.  
  340.     timer[i] = millis() - PTime[i]; // Resets the timer 11000 - 11000 = 0ms
  341.  
  342.     if (timer[i] < TIMEOUT) { // If the timer is less than the maximum allowed time it means that the potentiometer is still moving
  343.       potMoving = true;
  344.     }
  345.     else {
  346.       potMoving = false;
  347.     }
  348.  
  349.     if (potMoving == true) { // If the potentiometer is still moving, send the change control
  350.       if (midiPState[i] != midiCState[i]) {
  351.  
  352.         // Sends the MIDI CC accordingly to the chosen board
  353.         //#ifdef ATMEGA328
  354.         // use if using with ATmega328 (uno, mega, nano...)
  355.         MIDI.sendControlChange(cc + i, midiCState[i], midiCh); // cc number, cc value, midi channel
  356.         potPState[i] = potCState[i]; // Stores the current reading of the potentiometer to compare with the next
  357.         midiPState[i] = midiCState[i];
  358.       }
  359.     }
  360.   }
  361. }
  362.  
  363.  
  364.  
  365. /////////////////////////////
  366. ///////////PIEZOS
  367. void piezos() {
  368.   for (int i = 0; i < N_PIEZO; i++) {
  369.     int sensorValue = analogRead(PIEZO_ARDUINO_PIN[i]);
  370.     int MAX;
  371.  
  372.     if (sensorValue > 20 &&  piezo == false) {
  373.       int peak1 = analogRead(PIEZO_ARDUINO_PIN[i]);
  374.       MAX = peak1;
  375.       delay(1);
  376.       int peak2 = analogRead(PIEZO_ARDUINO_PIN[i]);
  377.  
  378.       if (peak2 > MAX) {
  379.         MAX = peak2;
  380.       }
  381.  
  382.       delay(1);
  383.       int peak3 = analogRead(PIEZO_ARDUINO_PIN[i]);
  384.  
  385.       if (peak3 > MAX) {
  386.         MAX = peak3;
  387.       }
  388.  
  389.       delay(1);
  390.       int peak4 = analogRead(PIEZO_ARDUINO_PIN[i]);
  391.  
  392.       if (peak4 > MAX) {
  393.         MAX = peak4;
  394.       }
  395.  
  396.       delay(1);
  397.       int peak5 = analogRead(PIEZO_ARDUINO_PIN[i]);
  398.  
  399.       if (peak5 > MAX) {
  400.         MAX = peak5;
  401.       }
  402.  
  403.       delay(1);
  404.       int peak6 = analogRead(PIEZO_ARDUINO_PIN[i]);
  405.  
  406.       if (peak6 > MAX) {
  407.         MAX = peak6;
  408.       }
  409.  
  410.       MAX = map(MAX, 20, 800, 1, 127);
  411.  
  412.       if (MAX <= 1) {
  413.         MAX = 1;
  414.       }
  415.  
  416.       if (MAX >= 127) {
  417.         MAX = 127;
  418.       }
  419.  
  420.  
  421.  
  422.  
  423.       MIDI.sendNoteOn(note + i, MAX, 1);
  424.       MIDI.sendNoteOff(note + i, 0, 1);
  425.       delay(20);
  426.       // Serial.println(MAX);
  427.  
  428.       piezo = true;
  429.  
  430.       delay(30); //mask time
  431.  
  432.     }
  433.  
  434.     if (sensorValue <= 0 && piezo == true) {
  435.       piezo = false;
  436.     }
  437.  
  438.   }
  439. }
  440. /////////////////////////////
  441. ///////////ENCODERS
  442. void encoders() {
  443.   for (int i = 0; i < N_ENCODERS; i++) {
  444.     encoderValue[ENCODER_MIDI_CH][i] = encoder[i].read(); // reads each encoder and stores the value
  445.   }
  446.  
  447.   for (int i = 0; i < N_ENCODERS; i++) {
  448.  
  449.     if (encoderValue[ENCODER_MIDI_CH][i] != lastEncoderValue[ENCODER_MIDI_CH][i]) {
  450.  
  451.       //#ifdef TRAKTOR // to use with Traktor
  452.       //if (encoderValue[ENCODER_MIDI_CH][i] > lastEncoderValue[ENCODER_MIDI_CH][i]) {
  453.       //encoderValue[ENCODER_MIDI_CH][i] = 127;
  454.       //} else {
  455.       //encoderValue[ENCODER_MIDI_CH][i] = 0;
  456.       //}
  457.  
  458.  
  459.       clipEncoderValue(i, encoderMinVal, encoderMaxVal); // checks if it's greater than the max value or less than the min value
  460.  
  461.       // Sends the MIDI CC accordingly to the chosen board
  462.  
  463.       MIDI.sendControlChange(ENCODER_CC_N[i], encoderValue[ENCODER_MIDI_CH][i], ENCODER_MIDI_CH);
  464.       lastEncoderValue[ENCODER_MIDI_CH][i] = encoderValue[ENCODER_MIDI_CH][i];
  465.     }
  466.   }
  467. }
  468. ////////////////////////////////////////////
  469. // checks if it's greater than maximum value or less than then the minimum value
  470. void clipEncoderValue(int i, int minVal, int maxVal) {
  471.  
  472.   if (encoderValue[ENCODER_MIDI_CH][i] > maxVal - 1) {
  473.     encoderValue[ENCODER_MIDI_CH][i] = maxVal;
  474.     encoder[i].write(maxVal);
  475.   }
  476.   if (encoderValue[ENCODER_MIDI_CH][i] < minVal + 1) {
  477.     encoderValue[ENCODER_MIDI_CH][i] = minVal;
  478.     encoder[i].write(minVal);
  479.   }
  480. }
  481.  
  482. /* When receiving MIDI from the daw the encoder updates itself and send midi back
  483.   this causes some sort of feedack. This function prevents the encoder to update itself
  484.   unti it stopped receiving midi from the daw.
  485. */
  486. void isEncoderMoving() {
  487.  
  488.   for (int i = 0; i < N_ENCODERS; i++) {
  489.  
  490.     if (encMoved[i] == true) {
  491.  
  492.       encPTime[i] = millis(); // Stores the previous time
  493.     }
  494.  
  495.     encTimer[i] = millis() - encPTime[i]; // Resets the encTimer 11000 - 11000 = 0ms
  496.  
  497.     if (encTimer[i] < encTIMEOUT) { // If the encTimer is less than the maximum allowed time it means that the encoder is still moving
  498.       encMoving[i] = true;
  499.       encMoved[i] = false;
  500.     }
  501.     else {
  502.       if (encMoving[i] == true) {
  503.         encoder[encoder_n].write(encTempVal);
  504.         encMoving[i] = false;
  505.       }
  506.     }
  507.   }
  508. }
  509. ////////////////////////////////////////////
  510. // checks if it's greater than maximum value or less than then the minimum value
  511. int clipValue(int in, int minVal, int maxVal) {
  512.  
  513.   int out;
  514.  
  515.   minVal++;
  516.  
  517.   if (in > maxVal) {
  518.     out = maxVal;
  519.   }
  520.   else if (in < minVal) {
  521.     out = minVal - 1;
  522.   }
  523.   else {
  524.     out = in;
  525.   }
  526.  
  527.   return out;
  528. }
  529.  
  530. //Linear interpolates a value in fromMap to toMap
  531. int multiMap(int value, int fromMap[], int fromMapSize, int toMap[], int toMapSize)
  532. {
  533.   //Boundary cases
  534.   if (value <= fromMap[0]) return toMap[0];
  535.   if (value >= fromMap[fromMapSize - 1]) return toMap[toMapSize - 1];
  536.  
  537.   //Find the fromMap interval that value lies in
  538.   byte fromInterval = 0;
  539.   while (value > fromMap[fromInterval + 1])
  540.     fromInterval++;
  541.  
  542.   //Find the percentage of the interval that value lies in
  543.   float fromIntervalPercentage = (float)(value - fromMap[fromInterval]) / (fromMap[fromInterval + 1] - fromMap[fromInterval]);
  544.  
  545.   //Map it to the toMap interval and percentage of that interval
  546.   float toIntervalPercentage = ((fromInterval + fromIntervalPercentage) / (fromMapSize - 1)) * (toMapSize - 1);
  547.   byte toInterval = (byte)toIntervalPercentage;
  548.   toIntervalPercentage = toIntervalPercentage - toInterval;
  549.  
  550.   //Linear interpolate
  551.   return toMap[toInterval] + toIntervalPercentage * (toMap[toInterval + 1] - toMap[toInterval]);
  552. }
  553.  
  554. void setColor (int vermelho, int verde, int azul) {
  555. #ifdef COMMON_ANODE
  556. vermelho = 255 - vermelho;
  557. verde = 255 - verde;
  558. azul = 255 - azul;
  559. #endif
  560. analogWrite (26, vermelho);
  561. analogWrite (27, verde);
  562. analogWrite (28, azul);
  563. analogWrite (29, vermelho);
  564. analogWrite (30, verde);
  565. analogWrite (31, azul);
  566. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement