# How to program sonicpi into another program?

**URL:** <https://in-thread.sonic-pi.net/t/how-to-program-sonicpi-into-another-program/527>\
**Category:** Creations & Ideas\
**Created:** [December 16, 2017, 5:16am UTC](https://in-thread.sonic-pi.net/t/how-to-program-sonicpi-into-another-program/527 "2017-12-16T05:16:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![micki](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@micki](https://in-thread.sonic-pi.net/u/micki)\
**Post date:** [December 16, 2017, 5:16am UTC](https://in-thread.sonic-pi.net/t/how-to-program-sonicpi-into-another-program/527/1 "2017-12-16T05:16:51Z")

</div>

i wanna connect a sonar to RPi to detect the distance,and play different pitches according to [it.So](http://it.So)…how can i write such program?  
maybe it sounds difficult… by the way; can i manage it by using “overtone”? and how?

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [December 16, 2017, 8:55am UTC](https://in-thread.sonic-pi.net/t/how-to-program-sonicpi-into-another-program/527/2 "2017-12-16T08:55:10Z")

</div>

Here’s an example I did last May based on an article in the MagPi magazine

---

<div class="post-metadata">

**Author:** ![micki](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@micki](https://in-thread.sonic-pi.net/u/micki)\
**Post date:** [December 16, 2017, 9:42am UTC](https://in-thread.sonic-pi.net/t/how-to-program-sonicpi-into-another-program/527/4 "2017-12-16T09:42:27Z")

</div>

yeah…thank u very much.  
to be honesty, i have just seen your article on

> **[Sonic Pi 3 says hello to Raspberry Pi GPIO](https://rbnrpi.wordpress.com/sonic-pi-3-says-hello-to-raspberry-pi-gpio/)**
>
> One of the requests that Sam Aaron, the Designer and Developer of Sonic Pi has received again and again over the last couple of years to allow Sonic Pi to be interactive with external devices such …

  
and it inspired me a lot.  
now your reply really touched me !  
toooooo much thanks.
