Pages: [1]   Go Down
Author Topic: Sharp IR Sensor with Arduino Board  (Read 1851 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

http://www.sparkfun.com/commerce/product_info.php?products_id=8959

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 618
Posts: 33938
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the reply, is this what you mean:

http://arduino.cc/en/Tutorial/AnalogInput

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 618
Posts: 33938
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Quote
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:-
Quote

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...   8-)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
The Roboduino Rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Check out the Roboduino Arduino-compatible board!


Melbourne, Victoria, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley ...much appreciated!
Logged

Pages: [1]   Go Up
Jump to: