Is this a statement or a question? You can use WS2812 if you only need MIDI output and no input, or if you have a board that's fast enough. MIDI input on AVR-based Arduino boards won't work reliably with WS2812 LEDs.
I am trying to understand..
Ok..but uploading some ws2812 animations on an arduino uno...there its a chance to use them conecting to a control.surface device..using two arduinos..
But thats not the point for me right now..i am working on encapsulated rgb leds..thanks for the advice on ws2812..i will try in a future anyway..
Now i got this code..only light up the first led, red colour, on 6 ledstrip (ws2812)
#include <Control_Surface.h>
USBMIDI_Interface usbmidi;
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
//Designamos nuestro pin de datos
#define PIN 40
//Designamos cuantos pixeles tenemos en nuestra cinta led RGB
#define NUMPIXELS 6
void setup() {
Control_Surface.begin();
pixels.begin();
}
void loop() {
Control_Surface.loop();
uint32_t rojo = pixels.Color(150,0,0);
pixels.setPixelColor(0, rojo); // Brillo moderado en rojo en el pixel numero 1 de nuestra tira de 6 leds
pixels.show(); // Mostramos y actualizamos el color del pixel de nuestra cinta led RGB
Why not? If you add using namespace ExtIO; at the top of your sketch, the same code should work with the shift register classes of Control Surface as well.
Ok..i see an example on your tutorial,getting started, i will try this right now, but i am confused because i was thought that shift registers only light leds when you press the button twice times..ok..sorry..
Let me show you the code i got for light leds with pedals (i got another leds for banks)..
So in this code,pins ( 38, 39, 40, 41, 42, 43, 44, and 45 ) check for a button if its pressed and light the led.
The buttons are in mux2 pins ( 8, 9, 10, 11, 12, 13, 14 and 15 ).
The point for me right now its to do the same on SPI shift-registers.
I have got two 74hc595..and are correctly wired (following your tutorial)..so i write this code..
#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>
Bank<8> bankpedal(4); /*El bank tiene 4 posiciones 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 4 posiciones 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 futton2 [] = { /*declarar los pines del multiplexer CD74HC4067 del tipo CCbuttonlatched y con nombre futton*/
{ mux2.pin(0), { 90, CHANNEL_1 } }, /* pin C0 del multiplexer en canal uno y con CC90*/
{ mux2.pin(1), { 94, CHANNEL_2 } },
{ mux2.pin(2), { 98, CHANNEL_3 } }, /*todos los botones del multiplexer encienden o apagan cada uno de los 8 pedales que configuremos en nuestro DAW (cubase,amplitube,etc)*/
{ mux2.pin(3), { 102, CHANNEL_4 } },
{ mux2.pin(4), { 106, CHANNEL_5 } },
{ mux2.pin(5), { 110, CHANNEL_6 } },
{ mux2.pin(6), { 114, CHANNEL_7 } },
{ mux2.pin(7), { 118, CHANNEL_8 } },
};
CCButtonLatched futton [] = {
{ mux2.pin(8), { 91, CHANNEL_1 } },
{ mux2.pin(9), { 92, CHANNEL_2 } },
{ mux2.pin(10), { 93, CHANNEL_3 } },
{ mux2.pin(11), { 95, CHANNEL_4 } },
{ mux2.pin(12), { 96, CHANNEL_5 } },
{ mux2.pin(13), { 97, CHANNEL_6 } },
{ mux2.pin(14), { 99, CHANNEL_7 } },
{ mux2.pin(15), { 100, CHANNEL_8 } },
};
// Instantiate a multiplexer
CD74HC4067 mux3 = {
A15, // input pin
{A11, A12, A13, A14}, // Address pins S0, S1, S2, S3
// 7, // Optionally, specify the enable pin
};
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, 5, 90, },
//{ 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*/
{bankpedal, mux3.pin(8), 66},
{bankpedal, mux3.pin(9), 67},
{bankpedal, mux3.pin(10), 68},
{bankpedal, mux3.pin(11), 69},
{bankpedal, mux3.pin(12), 1},
{bankpedal, mux3.pin(13), 2},
{bankpedal, mux3.pin(14), 3},
{bankpedal, mux3.pin(15), 4},
};
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*/
{bankamp, mux3.pin(0), 74},
{bankamp, mux3.pin(1), 75},
{bankamp, mux3.pin(2), 76},
{bankamp, mux3.pin(3), 77},
{bankamp, mux3.pin(4), 78},
{bankamp, mux3.pin(5), 79},
{bankamp, mux3.pin(6), 80},
{bankamp, mux3.pin(7), 80},
};
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,
{6, 7}, // button pins
{22, 27, 24, 29, 26, 23, 28, 25}, // 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,
{19, 18}, // button pins
{30, 31, 32, 33, 34, 35, 36, 37}, // LED pins
};
const pin_t ledPins[] = { 38, 39, 40, 41, 42, 43, 44, 45 };
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");
void setup() {
Control_Surface.begin();
for (auto pin : ledPins) // Set the pinMode to output for all LEDs
pinMode(pin, OUTPUT);
mux.begin();
sreg.begin();
for (Button &button : buttons)
button.begin();
}
void loop() {
// 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
sreg.digitalWrite(ledPins[i], futton[i].getState() ? HIGH : LOW);
// 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);
}
I doubt it, see Interrupt problems · FastLED/FastLED Wiki · GitHub.
A cheap solution for this would be to use a wemos d1 mini pro..but I am not interested on ws2812 leds right now