Modifications

MIDI TOY

2 793 octets ajoutés, 21 janvier 2014 à 16:21
aucun résumé de modification
</code>
Le code utilisé actuellement pour MIDI TOY version 4066
<code code lang='c'>
==== Partie software ====
 
Le code utilisé pour MIDI TOY version 4051
 
Pour l'instant pas commenté, mais il faut noter qu'il est nécessaire d'utiliser le point inhibit de la puce pour éviter un effet boucle sur le déclenchement des sons.
 
<code code lang='c'>
int incomingByte = 0; // for incoming serial data
 
const int nb = 12;
int inhibit = 7;
int out1 = 8;
int out2 = 9;
int out3 = 10;
char input [nb] = {
'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'Q', 'S'};
 
 
void setup() {
Serial.begin(9600);
pinMode(out1,OUTPUT);
pinMode(out2,OUTPUT);
pinMode(out3,OUTPUT);
pinMode(inhibit, OUTPUT);
}
 
void loop() {
if(Serial.available() > 0){
 
incomingByte = Serial.read();
 
for(int i=0; i<nb; i++){
if(incomingByte == input[i]){
switch(incomingByte){
case 'A':
/* Select Input 1 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, LOW);
digitalWrite(out2, LOW);
digitalWrite(out3, LOW);
delay(70);
break;
case 'Z':
/* Select Input 2 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, LOW);
digitalWrite(out2, LOW);
digitalWrite(out3, HIGH);
delay(70);
break;
case 'E':
/* Select Input 3 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, LOW);
digitalWrite(out2, HIGH);
digitalWrite(out3, LOW);
delay(70);
break;
case 'R':
/* Select Input 4 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, LOW);
digitalWrite(out2, HIGH);
digitalWrite(out3, HIGH);
delay(70);
break;
case 'T':
/* Select Input 5 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, HIGH);
digitalWrite(out2, LOW);
digitalWrite(out3, LOW);
delay(70);
break;
case 'Y':
/* Select Input 6 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, HIGH);
digitalWrite(out2, LOW);
digitalWrite(out3, HIGH);
delay(70);
break;
case 'U':
/* Select Input 7 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, HIGH);
digitalWrite(out2, HIGH);
digitalWrite(out3, LOW);
delay(70);
break;
case 'I':
/* Select Input 8 */
digitalWrite(inhibit, LOW);
digitalWrite(out1, HIGH);
digitalWrite(out2, HIGH);
digitalWrite(out3, HIGH);
delay(70);
break;
 
default:
digitalWrite(inhibit, HIGH);
delay(70);
}
}
}
}
else{
 
digitalWrite(inhibit, HIGH);
delay(70);
}
}
</code>
[[Catégorie:Arduino]]
Emailconfirmed
533
modifications