Need help connecting photoresistor to Max
Hi,
This is my first post on the forum and I've only been using Max for a couple of years and am entirely self-taught so apologies if I use some dodgy terminology.
Basically, I am undertaking a project whereby I want to connect a photoresistor to Max and use the data to replace one or more of the random number generators in a generative music patch that I have made. I want to be able to scale the data from the photoresistor to say, 0 to 10. The photoresistor will be measuring the level of ambient light in a room (as opposed to a D-Beam controller type of thing.)
Anyway, the thing I'm struggling with is interfacing the photoresistor with Max. From the little bit of Googling I have done, it seems that some kind of Arduino set up is the way to go but I was wondering if there would be a simpler and less costly way to get it all connected?
Thanks in advance,
Joshua
Hi
you can get hold of inexpensive Arduino clones quite cheaply from Rapid online, although in my experience they tend to be a little quirky. Try Amazon, Ebay, Sparkfun and coolcomponents to get the best price on a genuine board and you could be talking $20 or the equivalent; but be aware of counterfeits.
Using an LDR is simply a matter of building a voltage divider:
http://www.buildcircuit.com/voltage-divider-rule/
I know you want to use the ambient light, but I've personally found IR range finders more solid for remote gesture sensing. Depending on the range required a simple capacitive sensor might be suitable too. Or you could do blob tracking from your webcam.
The only way to get analog voltages from an LDR into Max is via a microcontroller, and Arduino might be the best way to go. I can write you a sketch and patch for your sensor when you decide on the platform that's best for you.
Brendan
Thanks Brendan, I really appreciate you taking the time to answer my question.
I've just bought an Arduino starter kit on Amazon which should be here in the next few days. Once I get it, I'll get everything hooked up but then I might need to contact you again as I've never done any kind of programming outside of Max.
Thanks again,
Joshua
Awesome, there's a photo resistor in the Arduino start kit. This playground will get you started:
Good luck and have fun!
Indeed, and this page has some nice graphics for us strictly visual learners:
Welcome to our Universe !
Brendan
ps
. . . . .waiting for the kit to arrive, is there any better feeling?
Ok, I am back after a brief hiatus. Had a few other projects to finish up and now I'm on a tight deadline with this installation as part of my University final project.
I have been getting to grips with the basics of Arduino and have worked out how to get readings from the LDR in the Arduino software. I have borrowed bits and pieces from various tutorials for this and I am happy with the sensitivity.
The only thing that remains is getting the data that is showing in the serial monitor of the Arduino app into Max.
Again, I apologise for any dodgy terminology here. I am approaching all of this as an artist with no background in electronics or computer science.
Thanks!
Hi
what is the format of the text/numbers you are reading in the serial monitor window in Arduino? Is it simply a stream of numbers, representing the changing current as you move your hand over the LDR? Are you only using one sensor? If so, all you need in Max is the following:
[fixed]
Brendan
Thanks Brendan,
The format of the numbers is indeed just a stream of numbers and I am only using one sensor. I have copied the attached patch into Max and modified my Arduino code as per your instructions but I am not getting any readings in Max. The serial port is correct so I'm not sure what else it could be.
Thanks again,
Josh
send me your patch and code
*mynamenospaces* at gmx dot com
Thanks Brendan, I've sent that over to you.
In the meantime
does the Arduino code generate numbers in the serial monitor window? Exactly what are you seeing in that window?
Are you on MacOS or Windows
I am on Mac OS and yes, the new Arduino code is generating numbers in the serial monitor but not in a list as per my original code, they are on a continuous line.
Ok, ignore the previous patch, try this:
Brendan
Hi Brendan, I'd just like to (belatedly) thank you again for all your help and advice.
I managed to get it working in the end and in fact, I think it was my fault that the original patch you sent me wasn't working as I had failed to follow your instructions carefully.
Cheers!
Josh