test effet hall + envoie message
This commit is contained in:
parent
8bd1d7510e
commit
4161892fc5
58
ressource arduino/MidiHall1/MidiHall1.ino
Normal file
58
ressource arduino/MidiHall1/MidiHall1.ino
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
/* capteur branché avec sortie sur pin24 arduino */
|
||||
bool EtatEntree = HIGH ;
|
||||
bool VarSuivi = HIGH ;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
pinMode(24,INPUT);
|
||||
Serial.begin(31250); /* initialisation d'un port serie au debit MIDI */
|
||||
noteOn(0x90, 0x55 , 0x00 ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
EtatEntree = digitalRead(24);
|
||||
if ( (EtatEntree != VarSuivi) && (EtatEntree == HIGH) )
|
||||
{
|
||||
noteOn(0x90, 0x55, 0x00) ;
|
||||
Serial.println("touche lachee");
|
||||
VarSuivi = HIGH;
|
||||
}
|
||||
|
||||
if ( (EtatEntree != VarSuivi) && (EtatEntree == LOW) )
|
||||
{
|
||||
noteOn(0x90, 0x55, 0x60) ;
|
||||
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); */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user