Working with Photoresistors (LDRs) on the Raspberry Pi with RNBO

Working with Photoresistors (LDRs) on the Raspberry Pi with RNBO

In this article we'll cover how to use some simple sensors with RNBO on the Raspberry Pi target.

⚙️
Before attempting this tutorial, make sure you're already familiar with the basics of exporting your RNBO patchers to the RPi and that your audio interface is working correctly with it.

Photoresistors (LDRs)

Things you'll need:

  • 1 x 1uf capacitor
  • 1 x Light Dependent Resistor (aka Photoresistor)
  • Breadboard
  • Hook up wires

We'll start by exporting the following patcher to the Raspberry Pi target:​

Basic Generative Polyphony


----------begin_max5_patcher---------- 9376.3oc6cs0jaaik9Y6eEnz7fsyHqP.vaZqsREmXO61yNw1kcx7RRJUThPp 4XJRMjT8kjZ5e6KtPJw6Wj.UqVlIyD2lDMHv4C3fuyAGbve97mMZt+cjvQf+ KvuBd1y9ym+rmweD6AOK9u+rQqstagqUHuXirhhB15LZr3UN17G5O+e8ZnQx C2XEXslDQBlQ7rl6RXEQI9cdaW634Rh3UFL9gr5jWOK1F4ub4n8k0eaT9Buw JZw0NdqlEPVDIZ4H0IJiAPES9enov9CDZhB32i+cDUSz8aHhegQi.+N6M+mm +b1+YbK66K7Wul3Ekz9hH2wa.i9AqPmEf+GhGIvJx4FB3i9t2u4Zeu6KSNgS d3ReuHOpjh+p+gUj+n5DRrRuzZAI8yxJgTZRBg3BHrhA+OzRIf15YSBbc7H4 +hgN+A+YrJPhRrOes+sgfnqIfMA9aHAQNjPf+R9S9z6+gO.90a7cVP9c.Uhw 5DEEiHTsRqNJYLDiYz04+gBSxHwd6aVvGU7OYcovj2Ne6734FvRFjnHmdGFB mnMFnpx6kS4.OqGK0t2mirh11t9koj.McCd2RAOAm9eLfiA5JGUmbMILzZEo PmDpLojQgFk1ePcVAlAelIGlR+OZFzdxTVWsOTmUUWszdJVR8TLrRjq+5odj ao8gBcTWeKalP..KoCq0ggp00gSVUh2uM5s0lpnKFEX4EtwOnLUnpc.RmVSO bJl2ofXwpv3l6hNLsH69ikTbnhenrRcXxm4aih78Jag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ugi.eZ7r4nOHMGgROx6Ubb2K9UJ+XtmgOT0ayYim t8S.kNXET5fxmRm3nI+0CiN3.itAFcCL5FXzMvn6qWFcvAFcWBL5f0vnCcXL 51gPECSs8j7Jy89on50bXoU0tMkaOEqkoYWaDlssQTnbE2rlGkFFr5FFrWZX pssgA6QXSM+VBUWi.1SMBrRaG7zmhB1Ndo1hFgdO2FvsnMn0ysATa.CydtQz lwkHidtQzpgkndrQfZq5cbe1HZqn.1qsBTKaE84HSD7b.OT5xPy9RuMr0CMU 5QYArsqvOsuaDsZgzdsUXz1oolmZZXsuogN0DwJF1asLZnjaqPqssh9j.Br0 rR6SJHv1tbiZe1HZ6pMn9TSOrsK2.6UcrJcXQuxWtYuou8WDgcXQCVeEIX8S Tf0SQ.VKh9qdMxu52n9RBQ7UyQ6U6hzqVEkWItnRryLWkZywhmkN5pOj7Tle +x9KI7HYS+V40ITo+O2u4N6cQ4nHqUYbqVYZYZQMhpqFy2uXNZi4JvEVKtlj uqsfJJWtOIZkzJR4r43Rj7EG4D9NusYc8MUwXPHQ3I+zMlX8X6ZILbKz5lzt aeD6uaybbHYQTIdrLocx82N6F3aFwKuG6GscarSHWrTe4TUs4u11TkPWDfX8 Z9ecoBzbp4R7TUC8QYaShu+tObMMAdxpvuDY091li2MNgN42PgTEv02a0N2c x.l8tHNUoBulNGn4hkLPAmSZ+7j+a7xGY8ZJuYWXor+74U6kzctVolnIOd0q 3O63C56fZ36fkz2A1v2AhjzGRooODTBeH8V7gPoH+dveHsV7gTkv2Aoeh9PY MtpdGbebenVL3dpj9NMNTPReGXK9NYGZKzEYsYS79cw+HrOwn0V+KAqHyw7+ pim3uxSR3iBHLkpwLB3OwJXw0NQzEL1FHTQdmtHYkLZsO0lWusNwl8x0xuee 4B2XsH9Rjz+tQO++77+e.ZVkBEA -----------end_max5_patcher-----------


To control the cutoff parameter of this patcher with an LDR, we'll write a quick python script on the Raspberry Pi to use alongside the rnbo runner - ssh in, or connect up a keyboard. We'll use a library that should already be on your RPi image called gpiozero and another for communicating with the runner via OSC. You can use any OSC library you like, this example will use pyliblo3.

To install pyliblo3 run the following two commands from the terminal on your RPi.

$ sudo apt install liblo-dev
$ pip install pyliblo3

Now create a file called RNBOPi_LDR.py by using nano or any other text editor you prefer

$ nano RNBOPi_LDR.py

Paste in the following script, then save the file.                            

from gpiozero import LightSensor
import liblo as OSC
import sys

# send all messages to port 1234 on the local machine
try:
    target = OSC.Address(1234)
except OSC.AddressError as err:
    print(err)    
    sys.exit()

# start the transport via OSC
OSC.send(target, "/rnbo/jack/transport/rolling", 1)

# read the sensor from GPIO
sensor = LightSensor(4)

while True:
    light_level = sensor.value
    print(light_level)
    OSC.send(target, "/rnbo/inst/0/params/cutoff/normalized", light_level)
RNBOPi_LDR.py

Now sudo poweroff the RPi, and disconnect the power. Let's create our circuit:

  1. 3.3v (red) from the RPi connects to one side of the LDR
  2. GND (black)  from the RPi connects to the ground bus rail
  3. The 1uf capacitor connects the shorter leg to the ground bus rail, the longer leg connects to the terminal strip inline with the LDR
  4. RPi GPIO 4 (blue) connects in between the LDR and the capacitor
RPI_LDR

The sensor.value from the LDR is already normalized - so we can use this directly to control the cutoff parameter via the normalized osc address. If you take a look in the patcher, you will see there is some logarithmic scaling of this via @fromnormalized which makes it feel more natural.

Switch the Pi back on and at the terminal run the script:

$ python RNBOPi_LDR.py

Now grab a torch and voila! You should be opening up and closing the filter with your light source.

lys.//

lys.//

I'm an audio programmer, data scientist, grad researcher and media artist from Melbourne, Australia. I specialise in DSP and interactive coding for sound design across a wide array of platforms.
Australia