Error - 'MIDI_controller' was not declared in this scope

Im very new to this and Im trying to program a MIDI button
I get the Error 'MIDI_controller' was not declared in this scope on line 14
Im, sure it's a simple fix
Could anyone help show me what's wrong and how to fix it?

Code:

---



```
#include <MIDI_controller.h> // Include the library

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t C4 = 60;              // Note number 60 is defined as middle C in the MIDI specification

Digital button(2, C4, 1, velocity);

void setupcolor=#000000[/color] { }

void loopcolor=#000000[/color] {

// Refresh the button (check whether the button's state has changed since last time, if so, send it over MIDI)
MIDI_controller.refreshcolor=#000000[/color];
}
```

|

Are there any examples with the library ?
Where did you get it from ?

As a wild guess you need to create an instance of the MIDI object and use that, but I also don't like the look of

Digital button(2, C4, 1, velocity)

I think ur right. But how would one do that?
I am terrible at this. (Noob)

Sorry

Something like

#include <MIDI_controller.h> // Include the library

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t C4 = 60;              // Note number 60 is defined as middle C in the MIDI specification

MIDI_controller myMIDI;

Digital button(2, C4, 1, velocity);

void setup() { }

void loop()
{
  // Refresh the button (check whether the button's state has changed since last time, if so, send it over MIDI)
  myMIDI.refresh();
}

But no guarantees because I have not seen the library

Where did you get it from ?

It's a Custom Library made by a guy as apart of this Instructables tutorial https://www.instructables.com/id/Custom-Arduino-MIDI-Controller/

Also, your new code had these errors

sketch_sep21b:7: error: expected initializer before 'myMIDI'
sketch_sep21b.ino: In function 'void loop()':
sketch_sep21b:16: error: 'myMIDI' was not declared in this scope
expected initializer before 'myMIDI'

There are examples with the library. Have you tried them ?

Yes the Examples come up with the error

sketch_sep21b.ino: In function 'void loop()':
sketch_sep21b:30: error: 'MIDI_controller' was not declared in this scope
'MIDI_controller' was not declared in this scope

This is the example Code

Code:

---



```
#include <MIDI_controller.h> // Include the library

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t C4 = 60;              // Note number 60 is defined as middle C in the MIDI specification

Digital button(2, C4, 1, velocity);

void setupcolor=#000000[/color] { }

void loopcolor=#000000[/color] {

// Refresh the button (check whether the button's state has changed since last time, if so, send it over MIDI)
MIDI_controller.refreshcolor=#000000[/color];
}
```

|

Which example is that ?

On the Github, it's the Ex.02.Button example

Im also using a Leonardo

reubenclarke_xml:
On the Github, it's the Ex.02.Button example

The library does not have an example of that name

Can you please post a link to the Github page ?

made by a guy as apart of this Instructables tutorial

Never ever use instrutables to learn stuff especially if you are a beginner. The quality of this web site is appalling and virtually every article I have seen contains error.

It is mainly written by beginners with an over inflated idea of their own abilities. Never trust a library where the examples don’t work.

Also please post code correctly using the </> code tabs icon, not the tables icon you used.
Read the how to use this forum sticky post.

Git Hub Link

Specific Example

The Instructable may have some issues but its the best and most comprehensive guide I have found. It's very clear and many other people have used It with great success. It's also the only one that uses a Leonardo Board instead of an Uno.

The Instructable may have some issues but its the best and most comprehensive guide I have found.

Then try looking harder, you will get into a mess with Instructable and here we are sick and tired of trying to clean up after their stupid mistakes. Most authors are so stupid that they can't draw a schematic of what they are presenting. They also confuse a Fritzing ( very crap ) layout diagram for a schematic.

It's very clear and many other people have used It with great success.

Read the comments, half of then say it doesn't work or ask for some stupidly impossible thing.

It's also the only one that uses a Leonardo Board instead of an Uno.

So now you tell us. I know you said that before but it was without the context that you were trying to follow the instructions for use with a Uno. It makes a difference, but not to the stupid mistake that he made with the example code.

However, it might make a difference to his library. The Leonardo uses a different processor to the Uno so any processor dependent features might not work. But it is capable of directly connecting to the USB port of a laptop and looking like a HID MIDI device. That means it doesn't need any helper applications like Hairless to run in your laptop.

Im very new to this and Im trying to program a MIDI button

To do what?

You might have multiple libraries installed that provide a "MIDI_controller.h" file. Delete all these other libraries, install the latest version of "tttapa/MIDI_controller" from GitHub, and try again.

That being said, the GitHub page clearly states that the MIDI Controller library is no longer supported.
It has been replaced completely by the Control Surface library.

The equivalent of the Ex.02.Button.ino example is NoteButton.ino.

Pieter

Doesn't matter anyway. I fixed the code.

reubenclarke_xml:
Doesn't matter anyway. I fixed the code.

I would be interested to see the fixed code. Please post it here so that we and future readers can benefit from seeing it