2019-08-09 21:18:26 +02:00
|
|
|
|
|
|
|
|
2019-09-20 21:56:16 +02:00
|
|
|
/* travail du 20/09/2019 modification du cablage pour essai gestion par port
|
|
|
|
|
|
|
|
|
|
|
|
| port A | Broche | note | MIDI hex |
|
|
|
|
| -------- | -------- | -------- | -------- |
|
|
|
|
| A0 | 22 | C2 | 24 |
|
|
|
|
| A1 | 23 | D2 | 26 |
|
|
|
|
| A2 | 24 | E2 | 28 |
|
|
|
|
| A3 | 25 | F2 | 29 |
|
|
|
|
| A4 | 26 | G2 | 2B |
|
|
|
|
| A5 | 27 | A2 | 2D |
|
|
|
|
| A6 | 28 | B2 | 2F |
|
|
|
|
| A7 | 29 | C3 | 30 |
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2019-10-04 17:43:24 +02:00
|
|
|
|
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
const int Masque1 = B00000001 ;
|
|
|
|
const int Masque2 = B00000010 ;
|
|
|
|
const int Masque4 = B00000100 ;
|
|
|
|
const int Masque8 = B00001000 ;
|
|
|
|
const int Masque16 = B00010000 ;
|
|
|
|
const int Masque32 = B00100000 ;
|
|
|
|
const int Masque64 = B01000000 ;
|
|
|
|
const int Masque128 = B10000000 ;
|
|
|
|
|
2019-10-04 17:43:24 +02:00
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
int RegistreA = 0xFF ;
|
2019-10-04 17:43:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
int EPA0 = B00000001 ;
|
|
|
|
int EPA1 = B00000010 ;
|
|
|
|
int EPA2 = B00000100 ;
|
|
|
|
int EPA3 = B00001000 ;
|
|
|
|
int EPA4 = B00010000 ;
|
|
|
|
int EPA5 = B00100000 ;
|
|
|
|
int EPA6 = B01000000 ;
|
|
|
|
int EPA7 = B10000000 ;
|
2019-10-04 17:43:24 +02:00
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
int DePA0 = 1 ;
|
|
|
|
int DePA1 = 2 ;
|
|
|
|
int DePA2 = 4 ;
|
|
|
|
int DePA3 = 8 ;
|
|
|
|
int DePA4 = 16 ;
|
|
|
|
int DePA5 = 32 ;
|
|
|
|
int DePA6 = 64 ;
|
|
|
|
int DePA7 = 128 ;
|
|
|
|
|
2019-08-16 21:51:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-09 21:18:26 +02:00
|
|
|
|
2019-08-09 21:36:53 +02:00
|
|
|
void setup()
|
2019-08-09 21:18:26 +02:00
|
|
|
{
|
2019-10-04 17:43:24 +02:00
|
|
|
pinMode(22,INPUT);
|
|
|
|
pinMode(23,INPUT);
|
2019-08-09 21:18:26 +02:00
|
|
|
pinMode(24,INPUT);
|
2019-08-16 21:51:50 +02:00
|
|
|
pinMode(25,INPUT);
|
2019-08-09 21:18:26 +02:00
|
|
|
pinMode(26,INPUT);
|
2019-08-16 21:51:50 +02:00
|
|
|
pinMode(27,INPUT);
|
2019-08-09 21:18:26 +02:00
|
|
|
pinMode(28,INPUT);
|
2019-10-04 21:26:18 +02:00
|
|
|
pinMode(29,INPUT);
|
|
|
|
|
|
|
|
|
|
|
|
/* DDRA = B11111111 ; /* initialisation du port A en entré sur toutes les broches */
|
2019-10-04 17:43:24 +02:00
|
|
|
|
|
|
|
|
2019-08-16 21:51:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-09 21:18:26 +02:00
|
|
|
Serial.begin(31250); /* initialisation d'un port serie au debit MIDI */
|
2019-10-04 21:26:18 +02:00
|
|
|
|
2019-09-20 21:56:16 +02:00
|
|
|
|
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
noteOn( 0x80, 0x24 , 0x00 ) ;
|
|
|
|
noteOn( 0x80, 0x26 , 0x00 ) ;
|
|
|
|
noteOn( 0x80, 0x28 , 0x00 ) ;
|
|
|
|
noteOn( 0x80, 0x29 , 0x00 ) ;
|
|
|
|
noteOn( 0x80, 0x2B , 0x00 ) ;
|
|
|
|
noteOn( 0x80, 0x2D , 0x00 ) ;
|
|
|
|
noteOn( 0x80, 0x2F , 0x00 ) ;
|
|
|
|
noteOn( 0x80, 0x30 , 0x00 ) ;
|
2019-09-20 21:56:16 +02:00
|
|
|
|
2019-08-16 21:51:50 +02:00
|
|
|
|
|
|
|
|
2019-08-09 21:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
void noteOn(int cmd, int pitch, int velocity) /* plays a MIDI note. Doesn't check to see that cmd is greater than 127,
|
|
|
|
or that data values are less than 127 */
|
|
|
|
{
|
|
|
|
Serial.write(cmd);
|
|
|
|
Serial.write(pitch);
|
|
|
|
Serial.write(velocity);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-20 21:56:16 +02:00
|
|
|
void loop()
|
2019-08-09 21:18:26 +02:00
|
|
|
{
|
2019-09-20 21:56:16 +02:00
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
RegistreA = PINA ; /* lecture du port A */
|
|
|
|
|
2019-09-20 21:56:16 +02:00
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
EPA0 = RegistreA & Masque1 ;
|
|
|
|
EPA1 = RegistreA & Masque2 ;
|
|
|
|
EPA2 = RegistreA & Masque4 ;
|
|
|
|
EPA3 = RegistreA & Masque8 ;
|
|
|
|
EPA4 = RegistreA & Masque16 ;
|
|
|
|
EPA5 = RegistreA & Masque32 ;
|
|
|
|
EPA6 = RegistreA & Masque64 ;
|
|
|
|
EPA7 = RegistreA & Masque128 ;
|
2019-09-20 21:56:16 +02:00
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
if ( ( EPA0 == 0 ) && ( DePA0 == 1 ) ) { noteOn(0x90, 0x24 , 0x70 ) ; }
|
|
|
|
if ( ( EPA0 == 1 ) && ( DePA0 == 0 ) ) { noteOn(0x80, 0x24 , 0x00 ) ;}
|
|
|
|
|
2019-10-04 17:43:24 +02:00
|
|
|
|
2019-09-20 21:56:16 +02:00
|
|
|
|
2019-10-04 17:43:24 +02:00
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
if ( ( EPA1 == 0 ) && ( DePA1 == Masque2 ) ) noteOn(0x90, 0x26 , 0x70 ) ;
|
|
|
|
if ( ( EPA1 == Masque2 ) && ( DePA1 == 0 ) ) noteOn(0x80, 0x26 , 0x00 ) ;
|
2019-10-04 17:43:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
if ( ( EPA2 == 0 ) && ( DePA2 == Masque4 ) ) { noteOn(0x90, 0x28 , 0x70 ) ;}
|
|
|
|
if ( ( EPA2 == Masque4 ) && ( DePA2 == 0 ) ) { noteOn(0x80, 0x28 , 0x00 ) ; }
|
|
|
|
|
|
|
|
if ( ( EPA3 == 0 ) && ( DePA3 == Masque8 ) ) { noteOn(0x90, 0x29 , 0x70 ) ;}
|
|
|
|
if ( ( EPA3 == Masque8 ) && ( DePA3 == 0 ) ) {noteOn(0x80, 0x29 , 0x00 ) ;}
|
|
|
|
|
|
|
|
if ( ( EPA4 == 0 ) && ( DePA4 == Masque16 ) ) { noteOn(0x90, 0x2B , 0x70 ) ;}
|
|
|
|
if ( ( EPA4 == Masque16 ) && ( DePA4 == 0 ) ) { noteOn(0x80, 0x2B , 0x00 ) ;}
|
|
|
|
|
|
|
|
if ( ( EPA5 == 0 ) && ( DePA5 == Masque32 ) ) { noteOn(0x90, 0x2D , 0x70 ) ;}
|
|
|
|
if ( ( EPA5 == Masque32 ) && ( DePA5 == 0 ) ) { noteOn(0x80, 0x2D , 0x00 ) ;}
|
|
|
|
|
|
|
|
if ( ( EPA6 == 0 ) && ( DePA6 == Masque64 ) ) { noteOn(0x90, 0x2F , 0x70 ) ;}
|
|
|
|
if ( ( EPA6 == Masque64 ) && ( DePA6 == 0 ) ) { noteOn(0x80, 0x2F , 0x00 ) ;}
|
|
|
|
|
|
|
|
if ( ( EPA7 == 0 ) && ( DePA7 == Masque128 ) ) { noteOn(0x90, 0x30 , 0x70 ) ;}
|
|
|
|
if ( ( EPA7 == Masque128 ) && ( DePA7 == 0 ) ) { noteOn(0x80, 0x30 , 0x00 ) ;}
|
2019-10-04 17:43:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DePA0 = EPA0 ;
|
|
|
|
DePA1 = EPA1 ;
|
|
|
|
DePA2 = EPA2 ;
|
|
|
|
DePA3 = EPA3 ;
|
|
|
|
DePA4 = EPA4 ;
|
|
|
|
DePA5 = EPA5 ;
|
|
|
|
DePA6 = EPA6 ;
|
|
|
|
DePA7 = EPA7 ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-20 21:56:16 +02:00
|
|
|
/* FIN */
|
2019-08-16 21:51:50 +02:00
|
|
|
|
2019-10-04 21:26:18 +02:00
|
|
|
|
|
|
|
}
|
2019-09-13 22:06:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|