Sharp IR Sensor with Arduino Board

Hi,

Im trying to do something which is probably quite simple to you guys but Im really struggling with it in my complete ignorance of Arduino!

Basically, I have one of these:

And I want to connect it to my Ardunio Board, in order to sense proximity.

Eventually I want to take the input information and use MAX/Jitter to create a visualization, but for the moment I just want to know how to get the sensor up and running.

I am a complete and utter beginner, I dont understand any of the jargon and I dont even know which wires to put into which pin!

I realize there is alot of info out there, almost too much, but I really dont have enough time to do random tutorials, and I cant find a tutorial which specifically relates to what I want to do.

Any help at all would be much appreciated!

Thanks very much

Rich

On the sensor:-
Pin 1 to the +5V of the Arduino
Pin 2 to the GND of the Arduino
Pin 3 to the Analogue input 0 of the Arduino

Then look in the playground at the program that is used to send signals from a potentiometer (pot) to the serial port and use that, it will behave just the same only you will be getting a signal proportional to the distance.

thanks for the reply, is this what you mean:

and when you say "program" do you mean that I take the code it gives there and put it into the Arduino software?

Thanks again

Yes that's the one
if you follow the wiring in my last post then change:-
int potPin = 2;
to
int potPin = 0;

that I take the code it gives there and put it into the Arduino software?

Yes and then up load it to the Arduino board. Then the LED will turn on and off with the sensor.

Then you can look at:-

http://www.arduino.cc/playground/Interfacing/MaxMSP

And instead of using the value read from the sensor to decide if you turn the LED on, use that number to send to max

Excellent, after a bit of messing around it seems to be working, I think I had the wires in the wrong way.

Now the LED blinks slowly when something is close to the sensor and quickly when something is far away.

Next step is to get things into MAX MSP!

Thanks again for you help... :sunglasses:

Something to note: while most IR sensors get messed up when in indirect or direct sunlight , the Sharp IR sensor emits a modulated signal and does not get messed up in sunlight. I've even used it in direct sunlight outside and it worked OK for relatively short distances.

The sun emits IR light which is what screws up the IR sensor.

I'd been wondering this aswell, thanks a lot for that help, Mike ;D

Ok now Ive managed to get my readings from the sensor into MAX MSP to drive a Jitter visualization and it's working reasonably well, although Im still tinkering with the preset values to make the visualization a bit more responsive.

What I want to do now is introduce 2 further sensors so that I have an array, then I will have 3 jitter visualizations which should be able to track the movement of a hand across them.

How do I link 3 sensors to the board? Do I need a breadboard, since there is only one GND pin?

thanks

That worked like a charm. I was searching to find a way to test my sensors to make sure they were still working. I am new to this all as well so that helped out a lot!

Shawn

excellent post! I've been doing some searches on how to interface IR sensors into max msp using the arduino as I am attempting a very similar project.

however rather than creating light/imagery I am attempting to use my sharp IR sensor as a MIDI controller for music applications within reason/ableton etc.

how did you go about sending the output of your IR sensor to MAX? did you need to convert this information into MIDI and then send to MAX or did you go about it another way?

So far I have been able to successfully connect the sensor with my arduino by using this following code:

int var1 = 0;

void setup() {
Serial.begin(9600);
}

void loop(){
var1 = analogRead(0);
Serial.print(var1);
Serial.println();
delay(1000);
}

I used this code to see if the sensor was working and used the serial monitor which showed that the sensor was indeed communicating the Arduino because a new line of code was being written as I moved my hand in front of the IR sensor - with the number changing depending how close or far away from the sensor my hand was.

I'm just at abit of a loss as what to do next/how to communicate with MAX MSP so I can send this information to my music software like Reason etc

Thanks alot for any help you can offer :slight_smile: ...much appreciated!