Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LcdBarGraphX.h>
- #include <LiquidCrystal.h>
- #include <LiquidCrystal_I2C.h>
- #include <Encoder.h>
- #include <Control_Surface.h> /*Program--include library-- then select "control surface" library..Vamos a programar el codigo con la librería Control Surface*/
- USBMIDI_Interface usbmidi; /*initializes device as usb_midi interface...see other examples like hardwareserial,hairles etc*/
- #include <Arduino_Helpers.h> // Include the Arduino Helpers library.
- #include <AH/Containers/ArrayHelpers.hpp>
- #include <AH/Hardware/Button.hpp>
- #include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>
- //#include <AH/Hardware/ExtendedInputOutput/SPIShiftRegisterOut.hpp>
- const int speedMultiplier = 1;
- byte lcdNumCols = 20; // -- number of columns in the LCD
- /* Caracteres personalizados */
- /*byte DIV_0_OF_5 [ 8 ] = {
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000
- }; // 0/5
- byte DIV_1_OF_5 [ 8 ] = {
- B10000,
- B10000,
- B10000,
- B10000,
- B10000,
- B10000,
- B10000,
- B10000
- }; // 1/5
- byte DIV_2_OF_5 [ 8 ] = {
- B11000,
- B11000,
- B11000,
- B11000,
- B11000,
- B11000,
- B11000,
- B11000
- }; // 2/5
- byte DIV_3_OF_5 [ 8 ] = {
- B11100,
- B11100,
- B11100,
- B11100,
- B11100,
- B11100,
- B11100,
- B11100
- }; // 3/5
- byte DIV_4_OF_5 [ 8 ] = {
- B11110,
- B11110,
- B11110,
- B11110,
- B11110,
- B11110,
- B11110,
- B11110
- }; // 4/5
- byte DIV_5_OF_5 [ 8 ] = {
- B11111,
- B11111,
- B11111,
- B11111,
- B11111,
- B11111,
- B11111,
- B11111
- }; // 5/5*/
- /*
- * Función de configuración de la pantalla LCD para la barra de progreso.
- * Utilice caracteres personalizados de 0 a 5 (6 y 7 permanecen disponibles).
- */
- /*void setup_progressbar () {
- Guardar caracteres personalizados en la memoria de la pantalla LCD */
- /* lcd.createChar ( 0 , DIV_0_OF_5);
- lcd.createChar ( 1 , DIV_1_OF_5);
- lcd.createChar ( 2 , DIV_2_OF_5);
- lcd.createChar ( 3 , DIV_3_OF_5);
- lcd.createChar ( 4 , DIV_4_OF_5);
- lcd.createChar ( 5 , DIV_5_OF_5);
- }
- */
- /**
- * Función dibujando la barra de progreso.
- *
- * @param percent El porcentaje que se mostrará.
- */
- Bank<8> bankpedal(4); /*El bank tiene 8posiciones o 4 ajustes de banco posibles <4> y se llama bank y tiene un rango de cuatro (4) por lo
- tanto crecerá o decrecerá cuatro valores*/
- Bank<8> bankamp(4); /*El bank tiene 8posiciones o 4 ajustes de banco posibles <4> y se llama bank2 y tiene un rango de cuatro (4) por lo
- tanto crecerá o decrecerá (4) valores*/
- /* Instantiate a multiplexer
- CD74HC4067 mux = {
- 15, // input pin
- {2, 3, 4, 14}, // Address pins S0, S1, S2, S3
- // 7, // Optionally, specify the enable pin
- };
- // Instantiate a shift register with the SPI slave select pin as latch pin, most
- // significant bit first, and a total of 16 outputs.
- SPIShiftRegisterOut<mux.length()> sreg = {SS, MSBFIRST};
- auto buttons = generateIncrementalArray<Button, mux.length()>(mux.pin(0));*/
- // Instantiate a multiplexer
- CD74HC4067 mux2 = {
- 8, // input pin
- {9, 10, 11, 12}, // Address pins S0, S1, S2, S3
- // 7, // Optionally, specify the enable pin
- };
- CCButtonLatched futton [] = { /*declarar los pines del multiplexer CD74HC4067 del tipo CCbuttonlatched y con nombre futton*/
- { mux2.pin(0), { 77, CHANNEL_1 } }, /* pin C0 del multiplexer en canal uno y con CC77
- { mux2.pin(1), { 81, CHANNEL_2 } },
- { mux2.pin(2), { 85, CHANNEL_3 } }, /*todosESTOS BOTOones del multiplexer encienden o apagan cada uno de los 8 pedales que configuremos en nuestro DAW (cubase,amplitube,etc)*/
- { mux2.pin(3), { 89, CHANNEL_4 } },
- { mux2.pin(4), { 93, CHANNEL_5 } },
- { mux2.pin(5), { 97, CHANNEL_6 } },
- { mux2.pin(6), { 101, CHANNEL_7 } },
- { mux2.pin(7), { 105, CHANNEL_8 } },
- };
- CCButtonLatched futton2 [] = {
- { mux2.pin(8), { 84, CHANNEL_1 } },
- { mux2.pin(9), { 86, CHANNEL_2 } },
- { mux2.pin(10), { 87, CHANNEL_3 } },
- { mux2.pin(11), { 88, CHANNEL_4 } },
- { mux2.pin(12), { 90, CHANNEL_5 } },
- { mux2.pin(13), { 91, CHANNEL_6 } },
- { mux2.pin(14), { 92, CHANNEL_7 } },
- { mux2.pin(15), { 94, CHANNEL_8 } },
- };
- // Instantiate a multiplexer
- CD74HC4067 mux3 = {
- A15, // input pin
- {A14, A13, A12, A11}, // Address pins S0, S1, S2, S3
- // 7, // Optionally, specify the enable pin
- };
- /*const int pinR4 = mux3.pin(8);
- const int pinR5 = mux3.pin(9);
- const int pinR6 = mux3.pin(10);
- const int pinR7 = mux3.pin(11);*/
- CCPotentiometer pots3 [] = {
- {mux3.pin(4), 74},
- {mux3.pin(5), 75},
- {mux3.pin(6), 76},
- {mux3.pin(7), 78},
- {mux3.pin(12), 79},
- {mux3.pin(13), 80},
- {mux3.pin(14), 82},
- {mux3.pin(15), 83},
- };
- Bankable::CCButtonLatched<8> bankbuttons [] = { /*declarar los botones que creceran o decreceran (4) valores dentro de cada cambio de banco.Serán del tipo ccbuttonlatched,se llamarán bankbuttons y los declaramos como bankables en los pines de salida 5 y 6 de arduino con los CC90 Y CC91 */
- { bankpedal, 7, 77, },
- //{ bankpedal, 6, 91, },
- };
- Bankable::CCPotentiometer pots[] = { /*declarar los potenciometros que creceran o decreceran (4) valores dentro de cada cambio de banco.Serán del tipo ccpotentiometer,se llamarán pots y los declaramos como bankables en los pines analogicos de salida A0,A1..ETC..de arduino con los CC66,CC67..ETC*/
- {bankamp, mux3.pin(8), 1},
- {bankamp, mux3.pin(9), 3},
- {bankamp, mux3.pin(10), 4},
- {bankamp, mux3.pin(11), 6},
- };
- Bankable::CCPotentiometer pots2[] = { /*declarar los potenciometros que creceran o decreceran (4) valores dentro de cada cambio de banco.Serán del tipo ccpotentiometer,se llamarán pots y los declaramos como bankables en los pines analogicos de salida A0,A1..ETC..de arduino con los CC66,CC67..ETC*/
- {bankpedal, mux3.pin(0), 37},
- {bankpedal, mux3.pin(1), 38},
- {bankpedal, mux3.pin(2), 39},
- {bankpedal, mux3.pin(3), 40},
- };
- IncrementDecrementSelectorLEDs<8> bankSelector = { /*declarar lo botones que van a incrementar o decrecer la posicion del cambio de banco dentro del banco llamado bank..como tiene cuatro bancos posibles..declaramos cuatro led pins para saber la posición del banco en el que estamos. Los botones que nos permitiran cambiar el banco serán los pines 2 y 3 en arduino*/
- bankpedal,
- {5, 6}, // button pins
- {30, 31, 32, 33, 34, 35, 36, 37}, // LED pins
- };
- IncrementDecrementSelectorLEDs<8> bankSelector2 = { /*declarar lo botones que van a incrementar o decrecer la posicion del cambio de banco dentro del banco llamado bank2..como tiene cuatro bancos posibles..declaramos cuatro led pins para saber la posición del banco en el que estamos. Los botones que nos permitiran cambiar el banco serán los pines 2 y 3 en arduino*/
- bankamp,
- {14, 15}, // button pins
- {38, 43, 44, 41, 42, 39, 40, 45}, // LED pins
- };
- CCRotaryEncoder enc = {
- {18, 19}, // pins
- 77, // address
- speedMultiplier, // multiplier
- 4, // pulses per click
- };
- /* Instantiate a CCAbsoluteEncoder object
- EncoderSelector<8> encoder = {
- bankamp,
- {18, 19}, // pins
- 1,
- Wrap::Clamp,// optional multiplier if the control isn't fast enough
- };*/
- const pin_t ledPins[] = { 22, 23, 24, 25, 26, 27, 28, 29 };
- template <class T, size_t N> constexpr size_t length(T (&)[N]) { return N; }
- static_assert(length(futton) == length(ledPins),
- "Error: requires same number of buttons as LEDs");
- LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
- LcdBarGraphX lbg(&lcd, lcdNumCols); // -- creating
- void setup() {
- Control_Surface.begin();
- for (auto pin : ledPins) // Set the pinMode to output for all LEDs
- pinMode(pin, OUTPUT);
- int status;
- lcd.begin(20, lcdNumCols);
- lcd.clear();
- lcd.setCursor(0,1);
- lcd.print ("Al loro.......");
- delay(1000);
- lcd.setCursor (5,3);
- lcd.print ("NENES...NENAS..");
- delay(800);
- lcd.clear();
- lcd.setCursor(1,2);
- lcd.print ("ELSEREBRODELABESTIA");
- delay(800);
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print ("LA PEDALERA MIDI");
- delay(500);
- lcd.setCursor(1,3);
- lcd.print ("Del Tio Elias");
- delay(1000);
- lcd.clear();
- lcd.setCursor(2,0);
- lcd.print ("YA ESTA AQUI!");
- delay(800);
- lcd.clear();
- lcd.setCursor(12,0);
- lcd.print ("jar");
- delay(500);
- lcd.clear();
- // -- do some delay: some time I've got broken visualization
- delay(100);
- /*-- initializing the LCD
- lcd.begin(4, lcdNumCols);
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print("LcdProgressBar*2");
- //-- Set min and max values
- //*** (0 is default minimum value)
- //*** (1023 is maximum value for both bars)
- lpg.setMaxValues(1023);
- delay(50);*/
- }
- /* Petit temps d'attente */
- /* mux.begin();
- sreg.begin();
- for (Button &button : buttons)
- button.begin();*
- }*/
- void loop() {
- /*int r4 = analogRead(pinR4);
- int r5 = analogRead(pinR5);
- int r6 = analogRead(pinR6);
- int r7 = analogRead(pinR7);
- //-- draw progress bars
- lpg.draw(r4, r5, r6, r7);*/
- // -- do some delay: frequent draw may cause broken visualization
- // put your main code here, to run repeatedly:
- Control_Surface.loop();
- for (size_t i = 0; i < length(futton); ++i)
- // Update the LED states to reflect the toggled switch states
- digitalWrite(ledPins[i], futton[i].getState() ? LOW : HIGH);
- lbg.drawValue( analogRead(mux3.pin(9)), 1023);
- // -- do some delay: frequent draw may cause broken visualization
- delay(100);
- }
- /*lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
- lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD
- lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD*/
- /* Check if a button is pressed, if so toggle the LED
- for (uint8_t i = 0; i < mux.length(); ++i)
- if (buttons[i].update() == Button::Falling)
- sreg.digitalWrite(i, sreg.digitalRead(i) ? LOW : HIGH);*/
Advertisement
Add Comment
Please, Sign In to add comment