tttapa / Control-Surface

Arduino library for creating MIDI controllers and other MIDI devices.
GNU General Public License v3.0
1.26k stars 140 forks source link

help wanted! no such file or directory #83

Open benwadub opened 4 years ago

benwadub commented 4 years ago

hi, i m really new to Arduino, I d like to make a simple midi controller with for the moment only 16 encoder on the Arduino Uno via midi din when I include the library I have a problem with the midi interface, ide say : SerialMIDI_Interface.hpp: No such file or directory

what am I doing wrong? I just dowloaded Arduino IDE thanks if someone can help me! if someone can show me how to write the sketch for this controller it could be nice! ps sorry for my approximative English I m French

benwadub commented 4 years ago

thanks again! I must admit I don t understand a lot of thing on what I m doing! I m not sure I ll be able to write the final code a day!

tttapa commented 4 years ago

I cannot reproduce your problem. The channel seems to be correct. Could you post your code and wiring diagram?

benwadub commented 4 years ago

hello! so here is the code

include // Include the Encoder library.

// This must be done before the Control Surface library.

include // Include the Control Surface library

USBDebugMIDI_Interface midi = 115200; //#include <MIDI_Interfaces/SerialMIDI_Interface.hpp>

include // Include the Arduino Helpers library

include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>

// Select the serial port to use. auto &serial = Serial; // Instantiate a Serial MIDI interface at the default MIDI baud rate. //SerialMIDI_Interface<decltype(serial)> midi = {serial, MIDI_BAUD //};

// You can also use the following serial MIDI interfaces: // // The Serial port that is connected to your computer over USB: // // USBSerialMIDI_Interface midi = 115200; // // A hardware serial port: // // HardwareSerialMIDI_Interface midi = {Serial1, MIDI_BAUD};

using namespace MIDI_Notes;

// Instantiate a NoteButton object //NoteButton button = { //5, // Push button on pin 5 //{note(C, 2), CHANNEL_5}, // Note C4 on MIDI channel 1 //};

// Instantiate a CCAbsoluteEncoder object CCAbsoluteEncoder enc1 = { {5, 6}, // pins {82, CHANNEL_1}, // MIDI address (CC number + optional channel) 16, // optional multiplier if the control isn't fast enough 4, //number of detent }; // Instantiate another CCAbsoluteEncoder object CCAbsoluteEncoder enc2 = { {7, 8}, // pins {82, CHANNEL_2}, // MIDI address (CC number + optional channel) 16, // optional multiplier if the control isn't fast enough 4, //number of detent }; // Instantiate another CCAbsoluteEncoder object CCAbsoluteEncoder enc3 = { {9, 10}, // pins {82, CHANNEL_3}, // MIDI address (CC number + optional channel) 16, // optional multiplier if the control isn't fast enough 4, //number of detent }; // Instantiate another CCAbsoluteEncoder object CCAbsoluteEncoder enc4 = { {11, 12}, // pins {82, CHANNEL_4}, // MIDI address (CC number + optional channel) 8, // optional multiplier if the control isn't fast enough 4, //number of detent }; // Instantiate another CCAbsoluteEncoder object CCAbsoluteEncoder enc5 = { {A0, A1}, // pins {82, CHANNEL_5}, // MIDI address (CC number + optional channel) 8, // optional multiplier if the control isn't fast enough 4, //number of detent }; // Instantiate another CCAbsoluteEncoder object CCAbsoluteEncoder enc6 = { {12, 13}, // pins {82, CHANNEL_6}, // MIDI address (CC number + optional channel) 16, // optional multiplier if the control isn't fast enough 4, //number of detent }; // Instantiate another CCAbsoluteEncoder object CCAbsoluteEncoder enc7 = { {A0, A1}, // pins {82, CHANNEL_7}, // MIDI address (CC number + optional channel) 16, // optional multiplier if the control isn't fast enough 4, //number of detent }; // Instantiate another CCAbsoluteEncoder object CCAbsoluteEncoder enc8 = { {A2, A3}, // pins {82, CHANNEL_8}, // MIDI address (CC number + optional channel) 16, // optional multiplier if the control isn't fast enough 4, //number of detent };

// Instantiate a multiplexer CD74HC4051 mux = { A5, // Analog input pin {2, 3, 4} // Address pins S0, S1, S2 };

//Instantiate multiplexer for 8 switch CCButton button[] = { {mux.pin(0), {82, CHANNEL_1}}, {mux.pin(1), {94, CHANNEL_2}}, {mux.pin(2), {94, CHANNEL_3}}, {mux.pin(3), {94, CHANNEL_4}}, {mux.pin(4), {94, CHANNEL_5}}, {mux.pin(5), {94, CHANNEL_6}}, {mux.pin(6), {94, CHANNEL_7}}, {mux.pin(7), {94, CHANNEL_8}}, }; void setup() { Control_Surface.begin(); // Initialize Control Surface

mux.begin(); // Initialize multiplexer mux.pinMode(0, INPUT_PULLUP); // Set the pin mode (setting it for one pin of } // the multiplexers sets it for all of them) void loop() {

Control_Surface.loop(); // Update the Control Surface }

and a superb drawing of my wiring :-) IMG_1036

and still message on channel 1 and 3 with the switch 21:31:05.020 -> Control Change Channel: 3 Data 1: 0x5e Data 2: 0x00 Cable: 0 21:31:06.379 -> Control Change Channel: 1 Data 1: 0x52 Data 2: 0x7f Cable: 0 21:31:06.379 -> Control Change Channel: 3 Data 1: 0x5e Data 2: 0x7f Cable: 0 21:31:06.519 -> Control Change Channel: 1 Data 1: 0x52 Data 2: 0x00 Cable: 0 21:31:06.519 -> Control Change Channel: 3 Data 1: 0x5e Data 2: 0x00 Cable: 0

and curious not the same message when push the button and when it come back

LukaszChrzanowski commented 4 years ago

You problably know it - only for reminder :) - but for testing purposes (eg. only one encoder connected to A0 on CD74HC4051) You should ground other "input" pins A1-A7 of multiplexer CD74HC4051 (to any Arduino GND).

It's CMOS - You will get a ton of garbage signals from "air". Try even blowing on multiplexer to get interesting results :)

this should get Your's case solved

benwadub commented 4 years ago

thanks Lucas, but I just found the problem, one of my cable was a faulty one apparently, I changed one by one each wire and I found that the one on S1 was a problem! with another cable all goes to one channel!!! but why does my switch send 2 different message? 22:01:37.936 -> Control Change Channel: 1 Data 1: 0x52 Data 2: 0x7f Cable: 0 22:01:38.082 -> Control Change Channel: 1 Data 1: 0x52 Data 2: 0x00 Cable: 0 22:01:38.392 -> Control Change Channel: 1 Data 1: 0x52 Data 2: 0x7f Cable: 0 22:01:38.535 -> Control Change Channel: 1 Data 1: 0x52 Data 2: 0x00 Cable: 0 and is it possible to see the cc number in the monitor instead of the strange numbers :-)?

LukaszChrzanowski commented 4 years ago

that was my problem too, about week ago.

1) if You ave any usuned pins from CD74HC4051 -> ground it! 2) check wiring - if You use breadboard - it will work like that :/ usually it's faulty connections - try soldier You project in prototype board. This really helps. :)

benwadub commented 4 years ago

ok so all is working fine now except 2 encoders sending on 2 channels but I think it s again faulty cables I ll see it later! I just add another mix for adding 8 switch that seems to work too could you just look the way I wrote the second mix and tell me if it s ok? it s working but I don t know if there is a better way to write it!

tttapa commented 4 years ago

but why does my switch send 2 different message?

It sends one message when you press it, and another when you release it.

and is it possible to see the cc number in the monitor instead of the strange numbers :-)?

The strange number is the cc number. It's hexadecimal (base 16), which is much more intuitive when dealing with binary protocols. Most MIDI implementation documents use hexadecimal to specify the CC numbers etc.
0x52 = 5×16+2 = 80 + 2 = 82.

If you really wanted to, you could change it to decimal by editing the source code.

I just add another mix for adding 8 switch that seems to work too could you just look the way I wrote the second mix and tell me if it s ok? it s working but I don t know if there is a better way to write it!

CD74HC4051 muxes[] = {
  { // mux 1
    A4, // Analog input pin
    {2, 3, 4} // Address pins S0, S1, S2
  },
  { // mux 2
    A5, // Analog input pin
    {2, 3, 4} // Address pins S0, S1, S2
  },
};
benwadub commented 4 years ago

Thanks! I was nearly good! I begin to understand lot of things with you! Really thank you for support!

benwadub commented 4 years ago

I m going to order what I need to solder one a board, I have a question that come to mind, when you solder you put the encoder in the hole of the board and solder the cable on the other side of the board directly on the pin of the encoder? Same thing for the switch?

tttapa commented 4 years ago

The encoder goes on the top side of the PCB (the side without copper), and then you solder it in place at the bottom. Then you insert the wire in the top side as well, through the hole next to the pin of the encoder you want to connect it to. Then you just solder it to the bottom as well. If you're using strip board, you might have to cut the trace. If you're using perfboard with single-hole copper, you can bend the wire towards the pin of the encoder before soldering, so you can easily connect it to the pin using some solder.

There are other ways, of course, but I find this one to be the easiest and cleanest.

benwadub commented 4 years ago

another question come :-) apparently my digitakt doesn't send values so is there a way to cancel "jump"midi value when I ll turn a potentiometer? or the only way is to use only encoder? encoder is a good solution but like I can t use mix on it I won t be able to use a lot of them...

benwadub commented 4 years ago

And what is for you the best solution to wire directly on the Arduino? I must solder my cables on the pins?

tttapa commented 4 years ago

Don't solder to the Arduino pins directly, use the correct connectors. I often buy "DuPont" cables, but I have no idea what the official name is.

benwadub commented 4 years ago

i have Dupont too, I was afraid this would not stay in place for long time but I ll begin like this! thanks again

benwadub commented 4 years ago

hello, i have soldered my midi module and encoder and all is fine!! while I was soldering I also made a midi input (maybe it will be useful in the future) in debug I see only things like this, ⸮<⸮⸮⸮x8⸮⸮<⸮⸮⸮<⸮8⸮<⸮⸮⸮8⸮⸮<⸮⸮⸮8⸮⸮⸮<⸮⸮⸮

do you Knox where the problem can come from? hardware or a software problem? to make it communicating I plugged it in the tx pin instead of the midi out to test

benwadub commented 4 years ago

Hi pieter, hope your exams have been good? Do you still plan to add encoders on multiplexer? I am on the beginning of the building and I don t know if I keep encoders or not cause I need lot of pins for them.

tttapa commented 4 years ago

in debug I see only things like this, ⸮<⸮⸮⸮x8⸮⸮<⸮⸮⸮<⸮8⸮<⸮⸮⸮8�⸮⸮<⸮⸮⸮8⸮⸮⸮<⸮⸮⸮

do you Knox where the problem can come from? hardware or a software problem? to make it communicating I plugged it in the tx pin instead of the midi out to test

Apologies, I seem to have missed your reply.

It looks like you are using the USBMIDI_Interface, the USBSerialMIDI_Interface, or the HardwareSerialMIDI_Interface instead of the USBDebugMIDI_Interface.
It's printing the binary MIDI messages instead of the human-readable debug messages.

Do you still plan to add encoders on multiplexer? I am on the beginning of the building and I don t know if I keep encoders or not cause I need lot of pins for them.

I've experimented with it, but I couldn't get it to work. The problem is getting the I2C interrupts to work inside of the ISR.

It shouldn't be too hard to make a polling version, without interrupts, but I don't have anything ready to add to the library yet.
You can of course write the encoder code yourself, and use the library for sending MIDI and everything else.

benwadub commented 4 years ago

Thanks for your reply. Btw I am absolute not able to write that kind of code alone! All I know on coding is what you teached me😅

benwadub commented 4 years ago

Hi, it s again me, I tried to use my controler over usb with my daw but my arduino une seems to not appear in my daw as midi interface, all is working fine with midi din, did I missed something? And is it possible to enable usb and serial interface at the same time please?

tttapa commented 4 years ago

The Arduino UNO doesn't support MIDI over USB:

https://tttapa.github.io/Control-Surface-doc/Doxygen/d8/d4a/md_pages_MIDI-over-USB.html

benwadub commented 4 years ago

Oh damn I haven’t seen it! For me I only need din so no problèm but a friend want to make the same controler as me for usb use, which one would you buy for him? The due seems a good solution for 16 encoder and 4 mux with pot and buttons

tttapa commented 4 years ago

I'd recommend a Teensy. It's cheaper and more powerful than a Due, and has better support. (Arduino doesn't really support the Due anymore, some libraries don't work with it, etc.)

benwadub commented 4 years ago

Thanks I ll check it! I just looked at it, it seems to be 3,3 volts? Will the hardware I already build be ok? My midi in out thru module by exemple?

tttapa commented 4 years ago

Due is also 3.3V.
I don't know of any powerful 5V microcontrollers.

Arduino Leonardo is 5V and has MIDI over USB support, but it's still an 8-bit AVR with little RAM etc.

The MIDI circuitry is very similar, but the resistor values are slightly different for 3.3V.

benwadub commented 4 years ago

hi Pieter, my soldering is finished, all is working fine except my encoders, on the uno or the mega they send value in a strange way, sometimes it jump + or- when I turn the clockwise, sometimes it jump lots of value, sometimes few, here is how I wrote them, have you an idea what I did wrong please? CCAbsoluteEncoder encoder [] = { {{6, 7}, {85, CHANNEL_9},16, 8,}, {{8, 9}, {86, CHANNEL_9}, 16, 4,}, {{10, 11}, {87, CHANNEL_9}, 1, 4,}, {{12, 13}, {88, CHANNEL_9}, 1, 4,}, {{14, 15}, {89, CHANNEL_9}, 1, 4,}, {{16, 17}, {90, CHANNEL_9}, 1, 4,}, {{18, 19}, {91, CHANNEL_9}, 1, 4,},

tttapa commented 4 years ago

I haven't tried this many encoders on a single Arduino.

Have you tried with just code for the encoders, without anything else?
Polling might be too slow, especially in combination with a lot of analog inputs.

benwadub commented 4 years ago

i forgot that encoders have to be used on pin with interrupt :-( the uno and the mega haven t enough so I ll have to use less encoder or buy a teensy. or maybe you have an other solution?

tttapa commented 4 years ago

I would think polling 7 encoders should work, but I might be wrong. Could you post your complete code?

benwadub commented 4 years ago

thanks for the quick reply! here is the code! if you also can show me how to add a led to my selector button it would be nice! I d like that the led is low when on bank 1 and led high when bank 2 is selected

#include <Encoder.h>

// celà doit etre écrit avant la library control surface
#include <Control_Surface.h> // Inclu la library control surface téléchargeable ici https://github.com/tttapa/Control-Surface en cliquant le bouton vert a droite
 //USBDebugMIDI_Interface midi = 115200; // enlever les // en début de ligne pour entrer en mode debug usb et voir dans le panneau de control si vos controler envoient bien les infos

auto &serial = Serial;// Selectionne le port série à utiliser

SerialMIDI_Interface<decltype(serial)> midi = {serial, MIDI_BAUD
};// démarre une interface midi serial au midi baud rate par defaut

//vous pouvez aussi utiliser l'interfaces midi usb en enlevant les // à la ligne suivante
//USBMIDI_Interface usbmidi;

//using namespace MIDI_Notes;  ces lignes midi servent à activer un bouton qui envoit une note midi enlever les // sur ces 5 lignes pour l'activer

// démarrer une touche midi
//NoteButton button = {
  //5,                       // numéro de l'entrée arduino sur laquelle le bouton est branché
  //{note(C, 2), CHANNEL_5}, // note C4 sur le canal 5 libre à vous de changer les numéro et d'en ajouter

// active un multiplexeur (une sorte de multiprise sur laquelle vous branchez 8 controleurs sur 1 seule entrée de l'arduino
CD74HC4051 mux1 = {
  A2,       // numéro de broche de l'arduino
  {2, 3, 4} // numéro de pins de l'arduino sur lesquels sont branchés tous les multiplexeurs apellés mux S0, S1, S2
};
Bank<2> bank2 = {8}; // active 2 bank avec 8 adresses par bank
//démarre un multiplexeur pour 8 boutons mute
Bankable::CCButtonLatched buttonmute[] = { //ces lignes déclarent le mux
  {{bank2,BankType::CHANGE_CHANNEL}, mux1.pin(0), {94, CHANNEL_1}},//numéro de bank correspondant/indique que le changement de bank change le canal midi (+8 car on a 8 adresses par bank)/pin sur laquelle le controleur est branché/numéro de cc/numéro de canal midi
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(1), {94, CHANNEL_2}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(2), {94, CHANNEL_3}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(3), {94, CHANNEL_4}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(4), {94, CHANNEL_5}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(5), {94, CHANNEL_6}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(6), {94, CHANNEL_7}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(7), {94, CHANNEL_8}},
};
Bank <2> bank3 = {8}; // 2 banks, 8 addresse per banks

Bank<2> bank1 = {-8}; // 2 banks, 8 addresse per banks

CD74HC4067 mux2 = {// deuxième multiplexeur cette fois si avec 16 entrées
  A1,              // analog pin
  {2, 3, 4, 5}, // Address pins S0, S1, S2, S3
  // 7, // Optionally, specify the enable pin
};
//Instantiate multiplexer for 16 switch
Bankable::CCPotentiometer fx [] = {
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(0), {83, CHANNEL_1}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(1), {83, CHANNEL_2}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(2), {83, CHANNEL_3}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(3), {83, CHANNEL_4}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(4), {83, CHANNEL_5}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(5), {83, CHANNEL_6}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(6), {83, CHANNEL_7}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(7), {83, CHANNEL_8}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(8), {82, CHANNEL_1}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(9), {82, CHANNEL_2}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(10), {82, CHANNEL_3}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(11), {82, CHANNEL_4}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(12), {82, CHANNEL_5}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(13), {82, CHANNEL_6}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(14), {82, CHANNEL_7}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(15), {82, CHANNEL_8}},
};

  //Instantiate second multiplexer for 8 potentiometer
CD74HC4051 mux3 = {
  A0,       // Analog input pin
  {2, 3, 4} // Address pins S0, S1, S2};

};
Bankable::CCPotentiometer fader [] = { //ici on déclare les faders avec comme vu plus haut le numéro de CC et le canal
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(0), {7, CHANNEL_1}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(1), {7, CHANNEL_2}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(2), {7, CHANNEL_3}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(3), {7, CHANNEL_4}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(4), {7, CHANNEL_5}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(5), {7, CHANNEL_6}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(6), {7, CHANNEL_7}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(7), {7, CHANNEL_8}},

};

CD74HC4051 mux4 = {
  A3,       // numéro de broche de l'arduino
  {2, 3, 4} // numéro de pins de l'arduino sur lesquels sont branchés tous les multiplexeurs apellés mux S0, S1, S2
};

CCAbsoluteEncoder encoder [16] = {
  {{6, 7}, {85, CHANNEL_9},16, 8,},
  {{8, 9}, {86, CHANNEL_9}, 16, 4,},
  {{10, 11}, {87, CHANNEL_9}, 16, 4,},
  {{12, 13}, {88, CHANNEL_9}, 1, 4,},
  {{14, 15}, {89, CHANNEL_9}, 1, 4,},
  {{16, 17}, {90, CHANNEL_9}, 1, 4,},
  {{18, 19}, {91, CHANNEL_9}, 16, 4,},
  {{20, 21}, {92, CHANNEL_9}, 1, 4,},
  {{22, 23}, {24, CHANNEL_9}, 1, 4,},
  {{24, 25}, {25, CHANNEL_9}, 1, 4,},
  {{26, 27}, {26, CHANNEL_9}, 1, 4,},
  {{28, 29}, {27, CHANNEL_9}, 1, 4,},
  {{30, 31}, {28, CHANNEL_9}, 1, 4,},
  {{32, 33}, {29, CHANNEL_9}, 1, 4,},
  {{34, 35}, {30, CHANNEL_9}, 1, 4,},
  {{36, 37}, {31, CHANNEL_9}, 1, 4,},

};
IncrementSelector<2> selectorbutton = { //déclare les boutons de changement de bank
  bank2, // banque sélectionnée
   mux4.pin(0), // pins sur lequel les boutons sont branchés
};
IncrementSelector<2> selectorbutton2 = {
  bank1, // banque sélectionnée
  mux4.pin(1),  // adresse du bouton
};
IncrementSelector<2> selectorvolume = {
  bank3, // banque sélectionnée
  mux4.pin(2),  
};

void setup() {
  Control_Surface.begin(); // initialise la library surface de control
}        

void loop() {
  Control_Surface.loop(); // Update the Control Surface
}
tttapa commented 4 years ago

Does it work without the potentiometers and multiplexers?

The Arduino's ADC is relatively slow. If you want to update 24 analog inputs, and read them twice to prevent crosstalk, it'll take at least (16+8) * 2 / (9615 Hz) = 5 ms, which may be too much delay to update the encoders correctly.

You can use the selectorbutton.get() method in your loop to get the bank setting and turn on/off an LED.

benwadub commented 4 years ago

I just ordered a teensy 3.5, I think with all it s interrupt it ll be easier! but I just saw that the last input have no holes to solder pins :-(

benwadub commented 4 years ago

Maybe this could help? https://github.com/buxtronix/arduino/tree/master/libraries/Rotary

tttapa commented 4 years ago

Why? How does it differ from the PJRC Encoder library?

benwadub commented 4 years ago

Really don t know 😂! I found this when I was looking what polling encoders mean.

benwadub commented 4 years ago

after a research I think that polling is using read function in the loop, am I right? I tried to write it in the loop but again failed :-(

here is the code if you can again send me in the right direction?

benwadub commented 4 years ago

hi, I just received my teensy 3.5, I adapted my midi interface with 47ohm resistor but I can t send anything with this midi out, is there something to adapt in the code to go from Arduino to teensy? the code seems to compile and work on Arduino with my first interface!

include

// celà doit etre écrit avant la library control surface

include // Inclu la library control surface téléchargeable ici https://github.com/tttapa/Control-Surface en cliquant le bouton vert a droite

//USBDebugMIDI_Interface midi = 115200; // enlever les // en début de ligne pour entrer en mode debug usb et voir dans le panneau de control si vos controler envoient bien les infos

auto &serial = Serial;// Selectionne le port série à utiliser

SerialMIDI_Interface<decltype(serial)> midi = {serial, MIDI_BAUD };// démarre une interface midi serial au midi baud rate par defaut

//vous pouvez aussi utiliser l'interfaces midi usb en enlevant les // à la ligne suivante //USBMIDI_Interface usbmidi;

//using namespace MIDI_Notes; ces lignes midi servent à activer un bouton qui envoit une note midi enlever les // sur ces 5 lignes pour l'activer

// démarrer une touche midi //NoteButton button = { //5, // numéro de l'entrée arduino sur laquelle le bouton est branché //{note(C, 2), CHANNEL_5}, // note C4 sur le canal 5 libre à vous de changer les numéro et d'en ajouter

Bank <2> bank3 = {8}; // 2 banks, 8 addresse per banks

//Instantiate second multiplexer for 8 potentiometer CD74HC4067 mux3 = { A0, // Analog input pin {2, 3, 4, 5} // Address pins S0, S1, S2};

}; Bankable::CCPotentiometer fader [] = { //ici on déclare les faders avec comme vu plus haut le numéro de CC et le canal {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(0), {7, CHANNEL_1}}, {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(1), {7, CHANNEL_2}}, {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(2), {7, CHANNEL_3}}, {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(3), {7, CHANNEL_4}}, {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(4), {7, CHANNEL_5}}, {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(5), {7, CHANNEL_6}}, {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(6), {7, CHANNEL_7}}, {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(7), {7, CHANNEL_8}},

}; void setup() { Control_Surface.begin(); // initialise la library surface de control

}
void loop() {

Control_Surface.loop(); // Update the Control Surface

}

tttapa commented 4 years ago

The hardware serial port on a Teensy is Serial1, not Serial.

tttapa commented 4 years ago

Polling means continuously reading the state of a pin. It's the opposite of an interrupt. An interrupt detects changes in hardware, and interrupts the main code when the state of the pin changes.

With an interrupt, you minimize the chances of missing a pin change, with polling, you have to make sure that you check the state of the pin often enough.

The PJRC Encoder library that is used by Control Surface falls back to polling if interrupts are not available for the given pin, so there's no need to write any special code.

benwadub commented 4 years ago

thanks for all this I ll try tomorrow!

benwadub commented 4 years ago

so in code I ll have to change serial by serial1 every time serial is written?

tttapa commented 4 years ago

No, just here:

auto &serial = Serial;// Selectionne le port série à utiliser