Pure Data: Light Dependent Resistor

Many possibilities:

https://forum.arduino.cc/t/receiving-changing-values-from-pure-data-to-arduino-via-osc/569917

https://wp.nyu.edu/computer_music/arduino-and-pure-data/

http://academy.kaziunas.com/tutorials/arduino_to_pd.php

https://www.artislab.it/en/send-8-bit-numbers-from-arduino-to-pure-data/


Breadboard Circuit

/images/basics/ldr_input_fritzing.png

Arduino Code

  • install osc from cnmat

#include <OSCMessage.h>

#ifdef BOARD_HAS_USB_SERIAL
#include <SLIPEncodedUSBSerial.h>
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
#else
#include <SLIPEncodedSerial.h>
 SLIPEncodedSerial SLIPSerial(Serial);
#endif

void setup() {

    Serial.begin(9600);
}

void loop() {

  int sensorValue = analogRead(A0);

  float voltage = sensorValue;

  // Serial.println(voltage);

  OSCMessage msg1("/brightness");
  msg1.add(voltage);
  SLIPSerial.beginPacket();
  msg1.send(SLIPSerial);
  SLIPSerial.endPacket();
  msg1.empty();

}

Pure Data Patch

The Pure Data receiver patch relies on the mrpeach externals: mrpeach GitHub Repository

They can be installed by cloning the repository to one of PD'2 search paths - or by using Deken. The external is named mrpeach: Instructions for using Deken

/images/basics/pd-arduino-ldr.png