Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 1 of 1

Thread: Teensy 3 Cant Do Note on/off with Bounce

  1. #1
    Junior Member
    Join Date
    Dec 2013

    Teensy 3 Cant Do Note on/off with Bounce

    I'm just trying to write a sketch in order to send a note on/off message. I've copied the code from the example. I just seem to get a random note appear now and then when using a simple max object.

    #include <Bounce.h>  // Bounce library makes button change detection easy
    #define kMidiChannel 1
    #define kMidiControl 1
    Bounce button1 = Bounce(1, 5);  // 5 = 5 ms debounce time
    void setup() {
      pinMode(1, INPUT_PULLUP);
    void loop() {
      int val = analogRead(14);
      val = map(val, 0, 1023, 0, 127);
      usbMIDI.sendControlChange(kMidiControl, val, kMidiChannel);
       // Note On messages when each button is pressed
      if (button1.fallingEdge()) {
        usbMIDI.sendNoteOn(60, 99, kMidiChannel);  // 60 = C4
      // Note Off messages when each button is released
      if (button1.risingEdge()) {
        usbMIDI.sendNoteOff(60, 0, kMidiChannel);  // 60 = C4
    Also, does the Bounce library use interrupts? Its just I thought if you want a MIDI message to take precedence you would need an interrupt?

    Edit: After taking away the CC send command, the problem went away which leads me to ask, how can I transmit CC messages and note messages at the same time efficiently?
    Last edited by daz1761; 03-24-2014 at 10:47 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts