proximity sensor and light

houdini's icon

hey guys, i am kinda new in using max msp and trying to figure something out.
for a project i have a patch with different leds that can be turned on/off and bascially operated in max.
btw these leds are connected to an arduino board and not the standard phidget interfacekit.

now i wanted to connect those leds with a proximity sensor so they will automatically turn on once you approach the sensor within 80 cm.

can someone help me how to figure out what to do. i tried to find patches on the internet for that kind of situation but there was nothing really that could help me ( at least that´s what i tought)

i appreciate any comment. tx in advance.

the patch is attached

5179.ledcontrolRGBnew.maxpat
Max Patch
Wetterberg's icon

doesn't sound like you even need max for this.

google "proximity sensor arduino code". Tons of readymade examples.

houdini's icon

since i already created a max patch it would be nice to stick to one format. also i can control the colour of the leds in the max patch now.
besides that, i do not have lot´s of experience in coding... or is there a possibility to translate the arduino code into max?

any suggestions?

brendan mccloskey's icon

I would echo Wetterberg's suggestion to optimize this in Arduino first. Furthermore, it could be argued that, as programming environments, Max is way more complex where Arduino is more straightforward.

You mention that you like being able to change LED colour; there's tutorials on how to do this quickly and simply on the Arduino site. Maybe you can define the interaction environment parameters a little more precisely for yourself - why, how and when LEDs react to proximity - before muddying the water with reading AND writing to Arduino via Max.

Brendan.

houdini's icon

true point, that´s something i still need to consider.

brendan mccloskey's icon

If I had more free time, I could suggest something simple in Arduino, but sadly under pressure at the moment. Search for terms like colour-changer, potentiometer, mood-light, LED, etc.

I'm certainly no coding-ninja, but this should be v simple.

HTH

Brendan

houdini's icon

tx again for your advice. i made the effort to code my stuff in arduino and it worked out perfectly! :)