---
title: "Making Sort of Palatable Music With an X-Band Motion Sensor"
url: "https://maker.wiznet.io/nagamma06/projects/making-sort-of-palatable-music-with-an-x-band-motion-sensor/"
markdown_url: "https://maker.wiznet.io/nagamma06/projects/making-sort-of-palatable-music-with-an-x-band-motion-sensor/md"
type: "UCC: User Created Content"
author: "hzimmerman"
author_url: "https://www.instructables.com/Making-sort-of-palatable-music-with-an-X-Band-moti/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "hzimmerman"
original_url: "https://www.instructables.com/Making-sort-of-palatable-music-with-an-X-Band-moti/"
published: "2023-01-31"
language: "en"
hardware: ["Arduino UNO", "Arduino Ethernet Shield"]
likes: 6
views: 525
comments: 1
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

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

> Making music with an X-Band radar

Original author: hzimmerman (source: https://www.instructables.com/Making-sort-of-palatable-music-with-an-X-Band-moti/)

## Components

- **Arduino UNO** x 1 ([docs](https://www.farnell.com/datasheets/1682209.pdf))
- **Arduino Ethernet Shield** x 1 ([docs](https://docs.arduino.cc/retired/shields/arduino-ethernet-shield-without-poe-module))
- Software: **Arduino IDE** ([docs](https://www.arduino.cc/en/software))
- Software: **Max**
- Software: **ableton**

## Article

## **Step 1: What Do We Need**

First the hardware:

- [A Parallax X-Band 10.525 GHz motion sensor Product ID: 32213](https://www.parallax.com/product/32213)

- [An Arduino Uno](http://www.arduino.cc/)

- A breadboard

- A red LED

- 7 wires to connect the Arduino to the breadboard

- A 1/4 watt 220 Ohm resistor

- A USB cable to connect the Arduino to your computer

- A computer, of course. For this instructable I used a Macbook Pro running OSX 10.10.3

Next the software:

- [The Arduino IDE](http://www.arduino.cc/en/Main/Software). I used version 1.6.4.

- [Max](https://cycling74.com/). I used version 7.0.3.

- [Ableton Live](https://www.ableton.com/). I used Live 9 suite.

## **Step 2: Building the Electronics**

![](https://content.instructables.com/FTT/QF8X/IATHEY74/FTTQF8XIATHEY74.jpg?auto=webp&frame=1&fit=bounds&md=13061a23e1f704435967ea7b34628d25) ![](https://content.instructables.com/FBW/AXXO/IATHEY75/FBWAXXOIATHEY75.jpg?auto=webp&frame=1&fit=bounds&md=7d2c080855249a0ad14a717edb38da64)

![](https://content.instructables.com/FC8/5CBY/IATHEY8H/FC85CBYIATHEY8H.png?auto=webp&frame=1&fit=bounds&md=fe56c99d42784103854f72fcc9cb7af1)

## **Step 3: What It Looks Like**

![What It Looks Like](https://content.instructables.com/FHA/YRLH/IATHEZCS/FHAYRLHIATHEZCS.jpg?auto=webp&frame=1&width=933&height=1024&fit=bounds&md=39ace2e6c8069589baf148fafb493ef6)

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

```c
// 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
```

![](https://content.instructables.com/FWP/21NJ/IATHCJ2M/FWP21NJIATHCJ2M.png?auto=webp&frame=1&fit=bounds&md=fbcb203a1a336cfc1e5db4ab28f7e9af)

![](https://content.instructables.com/FHJ/C2U2/IATHFBJX/FHJC2U2IATHFBJX.png?auto=webp&frame=1&fit=bounds&md=c6f57a81f9bfb8502aad5deafec32e41)

**Step 6: Max**

![](https://content.instructables.com/F6M/19CQ/IATHFCJH/F6M19CQIATHFCJH.png?auto=webp&frame=1&width=1024&height=1024&fit=bounds&md=b97da1cffc10f7c4bbb74591f372c79e) ![](https://content.instructables.com/FLM/WETE/IATHFCXR/FLMWETEIATHFCXR.png?auto=webp&frame=1&fit=bounds&md=9fc57758e2c46a329b405edd67671197)

![](https://content.instructables.com/F66/Q0MK/IATHFCYN/F66Q0MKIATHFCYN.png?auto=webp&frame=1&fit=bounds&md=64a7a11aabb5f928ba8ff93318c9def5)

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

![](https://content.instructables.com/F0U/5KIY/IATHFEKK/F0U5KIYIATHFEKK.png?auto=webp&frame=1&fit=bounds&md=161880c7e7e3e00ad8d691123b1799e3) ![](https://content.instructables.com/F3K/V83I/IATHFEKL/F3KV83IIATHFEKL.png?auto=webp&frame=1&fit=bounds&md=d54708b9ec9ea87e9e59508af9e6e8dc)
![](https://content.instructables.com/FXI/WRYG/IATHFE20/FXIWRYGIATHFE20.png?auto=webp&frame=1&fit=bounds&md=2a29c4256c22f113255008c6a704de5d) ![](https://content.instructables.com/FYO/5589/IATHFEUA/FYO5589IATHFEUA.png?auto=webp&frame=1&fit=bounds&md=a7e867748e9f2ac1776c111d1983e4e1)

```plaintext

```

---

Source: https://maker.wiznet.io/nagamma06/projects/making-sort-of-palatable-music-with-an-x-band-motion-sensor/
