Allora spiego meglio.. Sto progettando un midi controller (console per dj )... il programma che vi allego qui sotto funziona con arduino uno, ma io ho arduino leonardo e quando ho cambiato tipo di arduino nel programma selezionando il leonardo mi da dei problemi in : 'void setup()' , 'PIN_D6' che non è stato dichiarato , 'void loop()', 'void noteOn(byte, byte, byte)' , 'usbMIDI' che non è stato dichiarato e 'void noteOff(byte, byte)' ,'void controlChange(byte, byte, byte)' .gli errori li ho tracritti pure nel programma tranne L'usbMidi.. comunque il continuo del programma è nel file che vi ho allegato. Quello che chiedo è date le mie non conoscenze di linguaggio C e C ++ se poteste magari riscrivermi il programma in modo che funzioni con arduino leonardo :
// Basic MIDI Controller code for reading all of the Arduino's digital and analogue inputs
// and sending them as MIDI messages to the host PC.
//
// Authors: Michael Balzer
// Teensy USB-MIDI edit: Tim Crawford
//
// Revision History:
// Date | Author | Change
// ---------------------------------------------------
// 2011-02-22 | MSB | Initial Release
// 2011-03-01 | MSB | Updated MIDI output to send same MIDI signals as official MIDI Fighter
// | | Reduced debounce length from 5ms to 2ms
// 2011-03-14 | MSB | Modified analogue input logic so only pins moved within the timer
// | | period are updated, not all of them.
// | | Experimental code added for higher speed (but less accurate) analogue reads
// | | Reduced analogue timer length from 1000ms to 250ms
// 2011-03-21 | MSB | Removed TimerOne library. Each analogue pin now maintains its own time
// | | since it was last moved, rather than one timer for all pins. This stops
// | | sending jittery movements on analogue inputs which haven't been touched.
// 2011-04-11 | TC | Teensy USB code added.
// | MSB | Updated with #defines for Arduino Mega and Teensy USB for easy compilation
// 2011-10-23 | MSB | Added default #defines for Teensy 2.0 and Teensy++ 2.0 digital pins
// | | Removed #defines for Teensy 1.0 as usbMIDI is not supported
// 2012-01-20 | MSB | Updated to support Arduino 1.0 (updated Serial.print to Serial.write)
//
//
// This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// See http://creativecommons.org/licenses/by-nc-sa/3.0/ for license details.
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define ARDUINO_MEGA
#elif defined(__AVR_AT90USB646__)
#define TEENSY_PLUS_PLUS
#elif defined(__AVR_ATmega32U4__)
#define TEENSY_2
#elif defined(__AVR_AT90USB1286__)
#define TEENSY_PLUS_PLUS_2
#else
#define ARDUINO
#endif
// Uncomment this line to send debug messages to the serial monitor
//#define DEBUG
// Uncomment this line to enable outputs corresponding to the MIDI Fighter so MF mappings can be used in Traktor.
//#define MIDI_FIGHTER
//#define FASTADC
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
// MIDI mapping taken from http://www.nortonmusic.com/midi_cc.html
#define MIDI_CC_MODULATION 0x01
#define MIDI_CC_BREATH 0x02
#define MIDI_CC_VOLUME 0x07
#define MIDI_CC_BALANCE 0x08
#define MIDI_CC_PAN 0x0A
#define MIDI_CC_EXPRESSION 0x0B
#define MIDI_CC_EFFECT1 0x0C
#define MIDI_CC_EFFECT2 0x0D
#define MIDI_CC_GENERAL1 0x0E
#define MIDI_CC_GENERAL2 0x0F
#define MIDI_CC_GENERAL3 0x10
#define MIDI_CC_GENERAL4 0x11
#define MIDI_CC_GENERAL5 0x12
#define MIDI_CC_GENERAL6 0x13
#define MIDI_CC_GENERAL7 0x14
#define MIDI_CC_GENERAL8 0x15
#define MIDI_CC_GENERAL9 0x16
#define MIDI_CC_GENERAL10 0x17
#define MIDI_CC_GENERAL11 0x18
#define MIDI_CC_GENERAL12 0x19
#define MIDI_CC_GENERAL13 0x1A
#define MIDI_CC_GENERAL14 0x1B
#define MIDI_CC_GENERAL15 0x1C
#define MIDI_CC_GENERAL16 0x1D
#define MIDI_CC_GENERAL17 0x1E
#define MIDI_CC_GENERAL18 0x1F
#define MIDI_CC_GENERAL1_FINE 0x2E
#define MIDI_CC_GENERAL2_FINE 0x2F
#define MIDI_CC_GENERAL3_FINE 0x30
#define MIDI_CC_GENERAL4_FINE 0x31
#define MIDI_CC_GENERAL5_FINE 0x32
#define MIDI_CC_GENERAL6_FINE 0x33
#define MIDI_CC_GENERAL7_FINE 0x34
#define MIDI_CC_GENERAL8_FINE 0x35
#define MIDI_CC_GENERAL9_FINE 0x36
#define MIDI_CC_GENERAL10_FINE 0x37
#define MIDI_CC_GENERAL11_FINE 0x38
#define MIDI_CC_GENERAL12_FINE 0x39
#define MIDI_CC_GENERAL13_FINE 0x3A
#define MIDI_CC_GENERAL14_FINE 0x3B
#define MIDI_CC_GENERAL15_FINE 0x3C
#define MIDI_CC_GENERAL16_FINE 0x3D
#define MIDI_CC_GENERAL17_FINE 0x3E
#define MIDI_CC_GENERAL18_FINE 0x3F
#define MIDI_CC_SUSTAIN 0x40
#define MIDI_CC_REVERB 0x5B
#define MIDI_CC_CHORUS 0x5D
#define MIDI_CC_CONTROL_OFF 0x79
#define MIDI_CC_NOTES_OFF 0x78
#define NOTE_C0 0x00 // 0
#define NOTE_C1 0x12 // 18
#define NOTE_C2 0x24 // 36
edit by mod: per favore includi il codice usando gli appositi tag (2° avviso)
Il problema nasce da "usbMIDI" che pare un oggetto (ci sono le chiamate ad alcuni suoi metodi) ma di cui non vedo inclusa la libreria nello sketch da nessuna parte.
PS:
mi spieghi perché spezzi lo sketch in 2 tronconi, di cui uno incluso nel post ed un allegato come file DOC,?
devi:
se poteste magari riscrivermi il programma in modo che funzioni con arduino leonardo :
Riscriverti il programma è una richiesta assurda, mica siamo un centro assistenza a pagamento, quello che possiamo fare è dirti di fare questa modifica :
#define TEENSY_PLUS_PLUS
// #elif defined(__AVR_ATmega32U4__) // riga da commentare
#elif defined(ATmega32U4) // nuova riga
#define TEENSY_2
In pratica dici di compilare come se fosse una Tensey, usa lo stesso processore della Leonardo, così compila senza errori selezionando la Leonardo.