void notmain() { gpio_init(); timer_init(); midi_init(); midi_set_channel(CHANNEL_BEATS); while (1) { unsigned i; for (i = 0; i < sizeof(beats); i++) { midi_note_on(beats[i], 64); timer_wait_for(250000); midi_note_off(beats[i], 64); led_toggle(); } } while (1) { unsigned i; for (i = 20; i < 80; i += 5) { midi_note_on(i, 64); timer_wait_for(250000); midi_note_off(i, 64); led_toggle(); } } }
// the loop routine runs over and over again forever: void loop() { static int last_val = 0; //int sensorValue = analogRead(A0); int sensorValue = get_impulse(30); int mappedValue = min(0x7f, max(0, map(sensorValue, 0, 200, 0, 0x7f))); if (last_val != sensorValue) { //Serial.println(sensorValue); //Serial.println(mappedValue); midi_note_on(0, 37, sensorValue); delay(100); midi_note_on(0, 37, 0); } last_val = last_val; }