25 February 2026

Ignacio Vergara - Noise Makers

 

 

Noise Makers

Description

This week I built a simple MIDI instrument using three buttons and one potentiometer. The buttons trigger the notes, and the knob controls the pitch across two octaves.

Each button corresponds to a different note: C, D, and E. The potentiometer changes the MIDI note value over a 24-semitone range, which equals two octaves, since one octave consists of 12 consecutive semitones.

For each button, I mapped the knob to a specific MIDI range:

  • Button 1 (C): The knob controls values from 48 to 72, which corresponds to C3 up to C5
  • Button 2 (D): The knob controls values from 50 to 74, which corresponds to D3 up to D5.
  • Button 3 (E): The knob controls values from 52 to 76, which corresponds to E3 up to E5. 

To play the notes I used a software called Reaper which is a DAW program that allows me to attach a synthesizer to my MIDI instrument and play piano notes.


 Video Demonstration

 



 Photos









 Sketch

 

 

Schematic








Code

 

/*
 * MIDIUSB_test.ino
 *
 * Created: 4/6/2015 10:47:08 AM
 * Author: gurbrinder grewal
 * Modified by Arduino LLC (2015)
 */

#include "MIDIUSB.h"

// First parameter is the event type (0x09 = note on, 0x08 = note off).
// Second parameter is note-on/note-off, combined with the channel.
// Channel can be anything between 0-15. Typically reported to the user as 1-16.
// Third parameter is the note number (48 = middle C).
// Fourth parameter is the velocity (64 = normal, 127 = fastest).

void noteOn(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOn);
}

void noteOff(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOff);
}

int btn1 = 9;
int btn2 = 10;
int btn3 = 11;
const int knobPin = A0;

void setup() {
  Serial.begin(115200);
  pinMode(btn1, INPUT_PULLUP);
  pinMode(btn2, INPUT_PULLUP);
  pinMode(btn3, INPUT_PULLUP);
}

// First parameter is the event type (0x0B = control change).
// Second parameter is the event type, combined with the channel.
// Third parameter is the control number number (0-119).
// Fourth parameter is the control value (0-127).

void controlChange(byte channel, byte control, byte value) {
  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
  MidiUSB.sendMIDI(event);
}

void loop() {

  int knob = analogRead(knobPin);
 
  int note1 = map(knob, 0, 1023, 48, 72); // 1 octave is 12 consecutive semitones so this will go from C3 which is 48 to 72 which is C5
  int note2 = map(knob, 0, 1023, 50, 74);
  int note3 = map(knob, 0, 1023, 52, 76);

  // note 1

  if(digitalRead(btn1) == LOW){
    noteOn(0, note1, 64);   // Channel 0, middle C, normal velocity
    Serial.println("Sending note on");
  }
    if(digitalRead(btn1) == HIGH){
    noteOff(0, note1, 64);   // Channel 0, middle C, normal velocity
    Serial.println("Sending note on");
  }
  MidiUSB.flush();

  // note 2

    if(digitalRead(btn2) == LOW){
    noteOn(0, note2, 64);   // Channel 0, middle C, normal velocity
    Serial.println("Sending note on");
  }
    if(digitalRead(btn2) == HIGH){
    noteOff(0, note2, 64);   // Channel 0, middle C, normal velocity
    Serial.println("Sending note on");
  }
  MidiUSB.flush();

  // note 3

    if(digitalRead(btn3) == LOW){
    noteOn(0, note3, 64);   // Channel 0, middle C, normal velocity
    Serial.println("Sending note on");
  }
    if(digitalRead(btn3) == HIGH){
    noteOff(0, note3, 64);   // Channel 0, middle C, normal velocity
    Serial.println("Sending note on");
  }
  MidiUSB.flush();

}

 






No comments:

Post a Comment

Note: Only a member of this blog may post a comment.