Page 171 - MDP2020-1
P. 171

················································································  명장양성프로젝트  【MDP】  과제발표회  자료집  Ⅰ    |  165


                      bs19  =  true;
                  }else  if(bs19  &&  br19){
                      noteOff(0,  bn19,0);
                      bs19=  false;
                  }
                if(button==true){
                        flag=1;
                    }
                else  if(button  ==  false){
                    flag=0;
                }



                if(Serial.available()  >  0)
                {
                    byteData  =    Serial.read();
                    mySerial.write(  byteData);
                }
            }
            void  noteOn(byte  channel,  byte  note,  byte  attack_velocity)  {
                talkMIDI(  (0x90  |  channel),  note,  attack_velocity);
            }
            void  noteOff(byte  channel,  byte  note,  byte  release_velocity)  {
                talkMIDI(  (0x80  |  channel),  note,  release_velocity);
            }
            void  talkMIDI(byte  cmd,  byte  data1,  byte  data2)  {
                digitalWrite(ledPin,  HIGH);
                mySerial.write(cmd  );
                mySerial.write(data1  );
                if(  (cmd  &  0xF0)  <=  0xB0)
                    mySerial.write(data2  );
                digitalWrite(ledPin,  LOW);
            }
   166   167   168   169   170   171   172   173   174   175   176