Tutorial SRIO Library :
In this tutorial we will see how to use the library SRIO with Dilicktal Board
For this tutorial you need:
-1x Midilickuino
-1x Arduino
-1x à 8x Dilicktal
-Arduino software (version 1.0 or newer)
-SRIO Library_v1.2
-1x USB cable
SRIO Library description:
void Initialize(); //Initialize I / O used with Dilicktal void Led_SR_Write (byte SR_num, byte data); //Set a value of 8-bit shift register selected // number of Dilicktal from 0 to 7 (0 => first Dilicktal connected , 1 => second Dilicktal connected...) // Value sent from 0 to 255 // Example: // Led_SR_Write(0,255) turns all LEDs ON of the first Dilicktal in the chain. void Led_Pin_Write (byte Pin_num, byte flag); //Set 0 or 1 in the Pin Led selected // The number of pin ranges from 0 to 63 (0 being the first pin of the first Dilicktal ...) // value sent 1 => ON or 0 => OFF // Example: // Led_Pin_Write (34,1) Turn ON the third LED of the fifth Dilicktal in the chain. void Led_All_On(); // Turns all ON LEDs connected // Do not need any parameters void Led_All_Off(); // Turns all OFF LEDs connected // Do not need any parameters byte Led_SR_Read (byte SR_num); // Returns the value (8 bits) of the state of the LEDs on the Dilicktal board selected // Number of Dilicktal from 0-7 (0 => first Dilicktal connected, 1 => second Dilicktal connected ...) byte Button_SR_Read (byte SR_num); // Returns the value (8 bits) of the state of the buttons of the selected Dilicktal // Number of Dilicktal from 0-7 (0 => first Dilicktal connected, 1 => second Dilicktal connected ...) byte Button_Pin_Read (byte Pin_num); // Returns the state of the button, 0 => released or 1 => pressed // The number of pin ranges from 0 to 63 (0 being the first pin of the first Dilicktal ...) |
How to use SRIO Library:
Warning: The library SRIO only works with Arduino UNO, Pro, Duemilanove,
Diecimila, NG and Extreme.
For other Board, have a look on the forum here or contact us and we will send you the code to your Arduino Board
1-Copy the folder "SRIO" located in Zip file library
SRIO and paste it into the folder "libraries" of your Arduino environment
It is located in: X:/ .../arduino-1.0.x/libraries
You are now ready to use the library SRIO.
2-We will now create a simple code that uses the SRIO library functions
Launch Arduino and import our library
Go to "Sketch" then "Import Library ..." you should see SRIO, click on it.
Followed by "void setup" and "void loop"
In "void setup" entry initialization function library: SR.Initialize ()
Your code should look like the following:
#include <SRIO.h> void setup() { SR.Initialize(); } void loop() { } |
3-Let's have fun with this functions.
Connect Midilickuino with Arduino to your computer via USB
Now connect the Dilicktal Board to Midilickuino
The order in which you connect will give you the number of each Dilciktal and that each Pin.
4-We will create a code that will give us on the serial monitor of arduino
the number of each Dilicktal Board.
Here is the code and the comments so that you can understand how.
Upload the code and open the serial monitor by pressing CTRL + SHIFT + M
You should see a line that says: "The number board X is lit".
//////////////////////////////////////////////////////// //This program shows the number of each Dilicktal Board |
5-A little exercise, and yes!! do not believe that we will do the job for you.
Try doing the same thing but this time, it is necessary that the serial monitor shows
the number of each LED.
Use the function "Led_Pin_Write" instead of "Led_SR_Write"
Here is the answer: (Highlight the text to see the code)
//////////////////////////////////////////////////////// //This sketch shows the number of each led //////////////////////////////////////////////////////// #include <SRIO.h> //Variable of the number of connected led int nbr_led = 64; void setup() { //Initialize serial port Serial.begin(9600); //Initialize in and out use by Dilicktal SR.Initialize(); } void loop() { //Loops as many time as connected led for(int i=0; i<nbr_led; i++){ //Turn ON the selected Led SR.Led_Pin_Write(i,1); //Sent to the serial monitor the number of the led on Serial.print("the led number "); Serial.print(i,DEC); Serial.println(" is ON"); //delay for readability delay(2000); //Off the selected led SR.Led_Pin_Write(i,0); } } |
6-Now that we know how to use the functions of the LED we see that assigned to buttons.
We will create a code that will show us on the serial monitor of Arduino which button is pressed.
Here is the code commented:
//This sketch shows us wich button is pressed #include <SRIO.h> //Constant of the number of connected button #define nbr_button 64 //Variable of the button state //Array size is the number of button int button_state[nbr_button]; void setup() { //Initialize serial port Serial.begin(9600); //Initialize in and out use by Dilciktal SR.Initialize(); } void loop() { //Loops as many time as connected button for(int i=0; i<nbr_button; i++){ //Store button state in variable button_state[i]=SR.Button_Pin_Read(i); //Is the state ON? if(button_state[i] == 1){ //Sent to serial monitor the state of the button Serial.print("The "); Serial.print(i,DEC); Serial.println(" button is pressed"); } } } |
You will notice that in this code as we press the button the serial monitor displays
constantly: "The X button is pressed." You tell me that it poses no problem.
In this case also, but do not forget that we want to send MIDI event
so when the button is pressed all the time we send a MIDI message that will saturate the connection and
you can not send anything else as MIDI data.
7-the following execice will be displayed on the serial monitor the button state: pressed or
released. Courage is not complicated, you must use another
variable to hold the buttons states
Here is the answer: (Highlight the text to see the code)
///This sketch shows wich button is pressed or released |
8-Now that we have this code it is not very difficult to modify to send
MIDI data with our buttons.
Start by creating a function that sends control change message.
void Send_CC(byte num_CC, byte value) { Serial.write (0xB0);//Message "control change" on canal MIDI 1 Serial.write (num_CC); Serial.write (value); } |
To change the MIDI channel or message type you are referencing the Midilickuino Tutorial
Insert our function in our code and replace previous serial monitor messages to
a MIDI message
Add the "Led_Pin_Write" for the corresponding LED on the button lights up when pressed
Adding also the choice of the speed of serial communication
And here is the code:
//Sent MIDI message when a button is pressed or released |
Here it remains for you that making your own applications.
Other codes will be given as a choice between TOGGLE or MOMENTARY button or
Drum sequencer.... free rein to your imagination.
Follow us