Introduction: Build a Proximity Sensor With the Linkit One

Picture of Build a Proximity Sensor With the Linkit One

Proximity sensors are cool to work with especial when you are designing robots, let it be ultrasonic distance module or a IR proximity sensor. In this I'm going to show how to design your own IR proximity sensor with an bunch of IR LEDs and an Linkit One. Also checkout my previous instructables I have a cool series of Linkit One tutorials.

Step 1: Requirements

Picture of Requirements

Here is a list of all the electronic components required to get started with the circuit.

LinkIt One


IR Receiver diode

Step 2: Circuit

Picture of Circuit

The circuit is simple connect the IR LEDs in parallel and then to 3.3V power of the Linkit One. For the IR receiver you need to connect the anode to the Linkit One analog pin 0. Make sure you make the receiver and the IR LEDs face in the same direction.

Step 3: Code

The code lets you know each time any object is placed in proximity with the sensor. The code can be found below and you will require a modified Arduino IDE to work with the LinkIt One board to upload the code.

int IRpin = A0; // IR photodiode on analog pin A0
int IRemitter = 2; // IR emitter LED on digital pin 2 int ambientIR; // variable to store the IR coming from the ambient int obstacleIR; // variable to store the IR coming from the object int value[10]; // variable to store the IR values int distance; // variable that will tell if there is an obstacle or not

void setup(){ Serial.begin(9600); // initializing Serial monitor pinMode(IRemitter,OUTPUT); // IR emitter LED on digital pin 2 digitalWrite(IRemitter,LOW);// setup IR LED as off pinMode(11,OUTPUT); // buzzer in digital pin 11 }

void loop(){ distance = readIR(5); // calling the function that will read the distance and passing the "accuracy" to it Serial.println(distance); // writing the read value on Serial monitor // buzzer(); // uncomment to activate the buzzer function }

int readIR(int times){ for(int x=0;x

//-- Function to sound a buzzer for audible measurements --// void buzzer(){ if (distance>1){ if(distance>100){ // continuous sound if the obstacle is too close digitalWrite(11,HIGH); } else{ // beeps faster when an obstacle approaches digitalWrite(11,HIGH); delay(150-distance); // adjust this value for your convenience digitalWrite(11,LOW); delay(150-distance); // adjust this value for your convenience } } else{ // off if there is no obstacle digitalWrite(11,LOW); } }

Step 4:

Picture of

After uploading the code you can connect a battery to the Linkit one and test it by placing your palm in front of the IR sensor. I will be using this project to create a robot which I will be posting soon.


About This Instructable




Bio: Eat*Sleep*Code Repeat
More by Prem67:Build a Proximity Sensor with the Linkit OneLinkit One Play MusicLinkit One Oscilloscope
Add instructable to: