70 lines
1.9 KiB
Arduino
70 lines
1.9 KiB
Arduino
|
|
||
|
|
||
|
/* capteur branché avec sortie sur pin24 arduino */
|
||
|
bool EtatEntree24 = HIGH ;
|
||
|
bool VarSuivi24 = HIGH ;
|
||
|
bool EtatEntree26 = HIGH ;
|
||
|
bool VarSuivi26 = HIGH ;
|
||
|
bool EtatEntree28 = HIGH ;
|
||
|
bool VarSuivi28 = HIGH ;
|
||
|
|
||
|
void setup() ²
|
||
|
{
|
||
|
|
||
|
pinMode(24,INPUT);
|
||
|
pinMode(26,INPUT);
|
||
|
pinMode(28,INPUT);
|
||
|
Serial.begin(31250); /* initialisation d'un port serie au debit MIDI */
|
||
|
noteOn(0x80, 0x24 , 0x00 ) ; /* note off sur canal1 ; C2 ; vel 0 */
|
||
|
noteOn(0x80, 0x26 , 0x00 ) ; /* note off sur canal1 ; D2 ; vel 0 */
|
||
|
noteOn(0x80, 0x28 , 0x00 ) ; /* note off sur canal1 ; E2 ; vel 0 */
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
|
||
|
EtatEntree24 = digitalRead(24);
|
||
|
EtatEntree26 = digitalRead(24);
|
||
|
EtatEntree28 = digitalRead(24);
|
||
|
if ( (EtatEntree24 != VarSuivi24) && (EtatEntree24 == HIGH) )
|
||
|
{
|
||
|
noteOn(0x80, 0x24 , 0x00) ; /* note off sur canal1 ; C2 ; vel 0 */
|
||
|
/* Serial.println("touche lachee"); */
|
||
|
VarSuivi = HIGH;
|
||
|
}
|
||
|
|
||
|
if ( (EtatEntree != VarSuivi) && (EtatEntree == LOW) )
|
||
|
{
|
||
|
noteOn(0x90, 0x24 , 0x70) ; /* note on sur canal1 ; C2 ; vel */
|
||
|
/* Serial.println("touche appuyee"); */
|
||
|
VarSuivi = LOW;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/* // play notes from F#-0 (0x1E) to F#-5 (0x5A):
|
||
|
for (int note = 0x1E; note < 0x5A; note ++) {
|
||
|
//Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
|
||
|
noteOn(0x90, note, 0x45);
|
||
|
delay(100);
|
||
|
//Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
|
||
|
noteOn(0x90, note, 0x00);
|
||
|
delay(100); */
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|