Skip to content

Making Sort of Palatable Music With an X-Band Motion Sensor

Making music with an X-Band radar

nagamma06

Published January 31, 2023

Original author: hzimmermanOriginal source (new tab)

Making Sort of Palatable Music With an X-Band Motion Sensor

Components

Hardware components
Software Apps and online services

x 1


x 1


Project description

Step 1: What Do We Need

First the hardware:

Next the software:

Step 2: Building the Electronics

Step 2: Building the Electronics            Step 2: Building the Electronics

 

Step 2: Building the Electronics

Step 3: What It Looks Like


What It Looks Like

Step 4: Programming the Arduino - What Are We Going to Do

 

// Radar to MIDI note.
// 10.525 GHz X-Band Motion Detector (#32213) radar by www.parallax.com.
// Arduino: 1.6.2 (Mac OS X), Board: "Arduino Uno".
// Hens Zimmerman <hz37@xs4all.nl>
// June 10, 2015.

// Constants.

const int baudRate = 9600;
const int ledPin = 13;
const int maxCounter = 1000;
const int maxMIDI = 127;
const int usLoopDelay = 50;
const int xBandPin = 8;

// Initial code to run once.

void setup() 
{
  // Assign modes to pins.
  
  pinMode(xBandPin, INPUT);
  pinMode(ledPin, OUTPUT);  

  // Start serial communication to Max 7.
  
  Serial.begin(baudRate); 
}


// Loop code to run perpetually.

void loop() 
{
  // Create a small window in time during which we will count radar hits.
  // counter variable will count the amount of hits, so reset it at the start.

  int counter;
  counter = 0;

  // Start window in time.
  
  for(int idx = 0; idx < maxCounter; ++idx)
  {
      // Read value of motion sensor.
      
      int sensorValue = digitalRead(xBandPin);
      
      // Did we get a hit? Increment the counter.
      
      if(sensorValue)
      {
        ++counter;
      }
      
      // LED shows current status of sensorValue.
      
      digitalWrite(ledPin, sensorValue ? HIGH : LOW);
      
      // A small delay keeps things tidy.
      
      delayMicroseconds(usLoopDelay);
  }
 
  // Only output to serial if some motion was detected.
 
  if(counter)
  {
    // Scale to 7 bits.
    
    char output = map(counter, 0, maxCounter, 0, maxMIDI);

    // Output the number in 7 bit range.
    
    Serial.print(output);
  }
Step 5: Compile and Upload

 

Step 4: Programming the Arduino - What Are We Going to Do

Step 4: Programming the Arduino - What Are We Going to Do 

                                           Step 6: Max          

Step 4: Programming the Arduino - What Are We Going to Do            Step 4: Programming the Arduino - What Are We Going to Do            

Step 4: Programming the Arduino - What Are We Going to Do        

Step 5: Turning Random Notes Into a Scale in Ableton Live

Step 5: Turning Random Notes Into a Scale in Ableton Live Step 5: Turning Random Notes Into a Scale in Ableton Live
Step 5: Turning Random Notes Into a Scale in Ableton Live  Step 5: Turning Random Notes Into a Scale in Ableton Live    
                          

Comments

Comments