Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- // Set MIDI baud rate:
- Serial.begin(256000);
- }
- void loop() {
- int piez0 = analogRead(A0)/2;
- int piez1 = analogRead(A1);
- int piez2 = analogRead(A2);
- int piez3 = analogRead(A3);
- int vel0 = piez0/4;
- int vel1 = piez1/4;
- int noteON = 144;
- int noteOFF = 128;
- int hihat = 42;
- int snare = 43;
- int crash = 44;
- if (piez0 > 300) {
- MIDImessage(noteON, hihat, 127);
- delay(100);
- MIDImessage(noteOFF, hihat, 127);
- }
- if (piez1 > 300) {
- MIDImessage(noteON, snare, 127);
- delay(100);
- MIDImessage(noteOFF, snare, 127);
- }
- if (piez2 > 300) {
- MIDImessage(noteON, crash, 127);
- delay(200);
- MIDImessage(noteOFF, crash, 127);
- }
- }
- void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
- Serial.write(command);
- Serial.write(MIDInote);
- Serial.write(MIDIvelocity);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement