Matriz con hiduino

Hola, estoy usando una matriz con hiduino (tttapa) funciona como midi sin problemas, pero quiero hacer que cuando aprieto un boton se encienda un led en ese boton y cuando apriete otro, se encienda ese boton y se apaguen los demas.
lo de encender los leds, hay bastante informacion por la red y aunque no entiendo mucho de arduino poco a poco lo voy sacando.

El problema es que con un codigo sencillo que cuando aprieto el boton me pone el led en el mismo valor, no se como indicarle que pin es, ya que es una matriz.

#include "MIDI_Controller.h" // Include the library

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t matrix1[4][4] = {   // the note numbers corresponding to the buttons in the matrix
  {  1,  2,  3,  4 },
  {  5,  6,  7,  8 },
  {  9,  10,  11,  12 },
  { 13,  14,  15,  16 },
};

// Create a new instance of the class 'ButtonMatrix', called 'buttonmatrix', with dimensions 4 rows and 3 columns, with the rows connected to pins 2, 3, 4 and 5
// and the columns connected to pins 6, 7 and 8, that sends MIDI messages with the notes specified in 'addresses' on MIDI channel 1, with velocity 127
ButtonMatrix<4, 4> buttonmatrixa({2, 3, 4, 5}, {6, 7, 8, 9}, matrix1, 7, velocity);

int ledPin = 13;  // LED connected to digital pin 13
int pines1 = 2;
int pines2 = 6;

int val = 0;// variable to store the read value
int val1 = 0;

void setup() 

{
  pinMode(ledPin, OUTPUT);  // sets the digital pin 13 as output
  pinMode(pines1, INPUT);    // sets the digital pin 7 as input
  pinMode(pines2, INPUT);
}
 

void loop() {
  

  

  val = digitalRead(pines1) ;   // read the input pin
  val1 = digitalRead(pines2) ;

  digitalWrite(ledPin, val);  // sets the LED to the button's value
    digitalWrite(ledPin, val1); 

Se que habran muchos fallos, pero sigo buscando informacion para mejorarlo. gracias

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.