Arduino Sensor and resolume

Just let it all out, buddy. You're among friends here.
Post Reply
Kcathy
Posts: 3
Joined: Sun Apr 10, 2016 16:39

Arduino Sensor and resolume

Post by Kcathy »

Hi, im am currently doing my final year project and i am really stuck and need some help. For my project I am make an interactive installation and i am using an arduino and conductive paint. what i want to do is when the conductive paint is clicked it triggers a video to play in resolume. when the conductive paint is touched the numbers in the serial port change from 0 to 50-60's
I have downloaded hairless-midiserial but i am unsure how to use it with resolume and my touch sensor

any help would be really appreciative as im stuck for time, thanks.

this is my code for arduino:

Code: Select all

#include <Boards.h>
#include <Firmata.h>
 
 
#include <CapacitiveSensor.h>
 
CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4);
void setup()
{
 
Serial.begin(9600); }
 
void loop()
{ long start = millis(); 
long total5 = cs_2_4.capacitiveSensor(30);
 
 
Serial.print(millis() - start);        // check on performance in milliseconds
Serial.print("\t");                    // tab character for debug windown spacing
 
Serial.println(total5);                  // print sensor output 1
 
            // print sensor output 3
 
delay(100);                             // arbitrary delay to limit data to serial port
 
}
i also have it reading in processing aswel if thats any help:

Code: Select all

import processing.serial.*;
 
Serial myPort; // Create object from Serial class
 
String val; // Data received from the serial port
 
void setup() { size(400,400); myPort = new Serial(this, "/dev/tty.usbmodem1421", 9600); }
 
void draw()
 
{ if ( myPort.available() > 0)
 
{ // If data is available,
val = myPort.readStringUntil('\n'); // read it and store it in val
}
 
println(val); //print it out in the console
 
}

Zoltán
Team Resolume
Posts: 7483
Joined: Thu Jan 09, 2014 13:08
Location: Székesfehérvár, Hungary

Re: Arduino Sensor and resolume

Post by Zoltán »

if you get the data in processing, the next step is to parse that data, so you can decide what you want to do
then you need to send the commands to resolume from processing.

I would do that via OSC, but you can do it with midi too.
For osc you'll need the oscp5 library. Look at the samples for oscp5 on how to create a osc server.
Integrate the oscp5 to your sketch, and you'll be able to control anything in resolume.
Your sketch will be a bridge between the ardunio and resolume.
Software developer, Sound Engineer,
Control Your show with ”Enter” - multiple Resolume servers at once - SMPTE/MTC column launch
try for free: http://programs.palffyzoltan.hu

Kcathy
Posts: 3
Joined: Sun Apr 10, 2016 16:39

Re: Arduino Sensor and resolume

Post by Kcathy »

I started with oscP5 and have it downloaded but i am unsure how to use those sketches to do what i want. i also have syphon downloaded and did mange to use a syphon sketch to connect what is playing in resolume to show in the processing display, not sure if thats any help.

Would you know of any simple tutorials to help or would you be able to help me understand what to do, i am pretty new to this so a basic instruction would be greatly appreicated.

Thanks for your help :)

Zoltán
Team Resolume
Posts: 7483
Joined: Thu Jan 09, 2014 13:08
Location: Székesfehérvár, Hungary

Re: Arduino Sensor and resolume

Post by Zoltán »

look at the Mapping - OSC in resolume.
it will display the osc addresses you can send to resolume and the expected value types.
for example for launching layer 1 clip in column 1 you would send to the address. /layer1/clip1/connect
with the value 1

so for example, touching sensor 1 sends some data via serial, you check your received data in the processing sketch, if it's what you expected, then if it is, send an osc message to resolume. if it's not then check for another and so on.
Software developer, Sound Engineer,
Control Your show with ”Enter” - multiple Resolume servers at once - SMPTE/MTC column launch
try for free: http://programs.palffyzoltan.hu

User avatar
Oaktown
Resolume honorary member
Posts: 2837
Joined: Tue May 08, 2012 15:19
Location: Oakland, CA

Re: Arduino Sensor and resolume

Post by Oaktown »

Here is an interesting article for you: http://artandtech.aalto.fi/?page_id=550

User avatar
david@skyslc.com
Posts: 5
Joined: Fri Apr 15, 2016 02:58

Re: Arduino Sensor and resolume

Post by david@skyslc.com »

Make sure you check the hairless interface for errors and solve those if any before trying to work anything out in Resolume. If you get your note to show up in the Hairless interface when you close the circuit then it will be as easy as mapping any other midi controller.

Here's a Sketch I have from a similar project:

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
// Set MIDI baud rate:
Serial.begin(115200);
}

void loop() {
MIDI_TX(144,28,48); // NOTE ON
delay(5000); // Wait 5 sec before sending note again.
}

void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
Serial.write(MESSAGE);
Serial.write(PITCH);
Serial.write(VELOCITY);
}

Zoltán
Team Resolume
Posts: 7483
Joined: Thu Jan 09, 2014 13:08
Location: Székesfehérvár, Hungary

Re: Arduino Sensor and resolume

Post by Zoltán »

in fact you can control resolume via midi too, then you'll need a midi interface on the computer.
Changing code and midi mappings on the fly is not the easiest way, but osc messages are assigned to the functions already, so I think you would be better off changing the processing sketch code.

Anyhow, I would advise you to write your code in a way that you only send the triggers to resolume on sensor state changes, so not constantly in a loop.

here is a link regarding ardunio and midi, https://www.arduino.cc/en/Tutorial/Midi
Software developer, Sound Engineer,
Control Your show with ”Enter” - multiple Resolume servers at once - SMPTE/MTC column launch
try for free: http://programs.palffyzoltan.hu

Kcathy
Posts: 3
Joined: Sun Apr 10, 2016 16:39

Re: Arduino Sensor and resolume

Post by Kcathy »

I am unsure how to use oscp5 with a sensor to control resolume, there are not a lot of tutorial or guide which show how to do this and are understandable for a beginner. if some one could help me in how to achieve my goal of a conductive paint sticker playing a particular video in resolume either by oscp5 or midi it would be a big help. and how to connect either of these methods with resolume? Thanks :)

i combine a sketch with my code in hairless and this is what was reading in the hairless serial
+181.612 - Serial In: Ch 1: Note 49 on velocity 9
+181.612 - Serial In: Ch 1: Note 49 on velocity 9
+181.616 - Serial In: Ch 1: Note 13 on velocity 10
+181.62 - Serial In: Ch 1: Note 28 on velocity 48
+182.111 - Serial In: Ch 1: Note 49 on velocity 9
+182.115 - Serial In: Ch 1: Note 54 on velocity 55
+182.115 - Serial In: Ch 1: Note 13 on velocity 10
+182.119 - Serial In: Ch 1: Note 28 on velocity 48
+182.615 - Serial In: Ch 1: Note 49 on velocity 9...

Code: Select all

#include <MIDI.h>
#include <Boards.h>
#include <Firmata.h>


#include <CapacitiveSensor.h>

CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4);

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
// Set MIDI baud rate:
Serial.begin(9600);
}

void loop() {

long start = millis(); 
long total5 = cs_2_4.capacitiveSensor(30);

  
Serial.print(millis() - start);        // check on performance in milliseconds
//Serial.print("cc ch 10 ctrl 12 val = ");                    // tab character for debug windown spacing
 Serial.print("\t");   
Serial.println(total5);  

  
MIDI_TX(144,28,48); // NOTE ON
delay(500); // Wait 5 sec before sending note again.
}

void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
Serial.write(MESSAGE);
Serial.write(PITCH);
Serial.write(VELOCITY);
}

Zoltán
Team Resolume
Posts: 7483
Joined: Thu Jan 09, 2014 13:08
Location: Székesfehérvár, Hungary

Re: Arduino Sensor and resolume

Post by Zoltán »

see the controlling resolume section of the manual here: http://resolume.com/manual/en/r5/controlling
if you want to use midi directly from the ardunio, see the midi section, if you'll go thru processing, see the osc section.
You have to decide which way you want to go.

developing a program, flow charts are a big help to see the task you want to do.
it is also easier to break up the big task into smaller ones.
so you don't need to do sensor to osc in one step, break it up.
sensor to state data,
data transfer,
data parse,
osc packet creation, and sending.

in the ardunio loop I would do something like this:
for every sensor, check if the touch sensor state has changed, if yes, send the sensor id and new state to processing.
in processing, on incoming data, check data, and assembe an osc packet to send to resolume based on the data, then send it.

BTW, learning programming is good use of your time, so I'd encourage you to figure this out using the tutorials and examples yourself instead of asking someone to do the work :)
Software developer, Sound Engineer,
Control Your show with ”Enter” - multiple Resolume servers at once - SMPTE/MTC column launch
try for free: http://programs.palffyzoltan.hu

User avatar
david@skyslc.com
Posts: 5
Joined: Fri Apr 15, 2016 02:58

Re: Arduino Sensor and resolume

Post by david@skyslc.com »

You're almost there. You need LoopBe installed and you need to select LoopBe as your output in Hairless this is to take signal from Hairless to Resolume. In resolume go to midi and select LoopBe.
Kcathy wrote:I am unsure how to use oscp5 with a sensor to control resolume, there are not a lot of tutorial or guide which show how to do this and are understandable for a beginner. if some one could help me in how to achieve my goal of a conductive paint sticker playing a particular video in resolume either by oscp5 or midi it would be a big help. and how to connect either of these methods with resolume? Thanks :)

i combine a sketch with my code in hairless and this is what was reading in the hairless serial
+181.612 - Serial In: Ch 1: Note 49 on velocity 9
+181.612 - Serial In: Ch 1: Note 49 on velocity 9
+181.616 - Serial In: Ch 1: Note 13 on velocity 10
+181.62 - Serial In: Ch 1: Note 28 on velocity 48
+182.111 - Serial In: Ch 1: Note 49 on velocity 9
+182.115 - Serial In: Ch 1: Note 54 on velocity 55
+182.115 - Serial In: Ch 1: Note 13 on velocity 10
+182.119 - Serial In: Ch 1: Note 28 on velocity 48
+182.615 - Serial In: Ch 1: Note 49 on velocity 9...

Code: Select all

#include <MIDI.h>
#include <Boards.h>
#include <Firmata.h>


#include <CapacitiveSensor.h>

CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4);

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
// Set MIDI baud rate:
Serial.begin(9600);
}

void loop() {

long start = millis(); 
long total5 = cs_2_4.capacitiveSensor(30);

  
Serial.print(millis() - start);        // check on performance in milliseconds
//Serial.print("cc ch 10 ctrl 12 val = ");                    // tab character for debug windown spacing
 Serial.print("\t");   
Serial.println(total5);  

  
MIDI_TX(144,28,48); // NOTE ON
delay(500); // Wait 5 sec before sending note again.
}

void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
Serial.write(MESSAGE);
Serial.write(PITCH);
Serial.write(VELOCITY);
}

Post Reply