Introduction
Hey folks! Another interesting topic to discuss and share! Integrating sensors to an Arduino board seems interesting and feels good, when you receive the desired digital output and manipulate it. Nowadays, hundreds of different kinds of sensors are available in the market. We need to try out and explore how we can improve the user experiences using these electronics. For example, temperature monitoring sensors, obstacles detection sensor, soil moisture detection sensors, heart pulse rate sensors, and many more. I will try and use as many sensors as I can and try to integrate them with more sophisticated devices. In this article, I will be sharing about the IR Obstacle sensor, which as the name suggests detects an object or any obstacle coming the sensor's way! Let's see how.
The sensor
Here is how the sensor looks. We will see another pictorial representation of the above sensor and discuss about the details of the part.
The pictorial representation is given below:
Let's learn and see what the sensor has. As you can see, the numbers are mentioned. We will discuss the workaround and try to understand each and every word. First one goes like:
Sensor Parts |
Functions |
OUTPUT |
This port in the sensor sends the digital output to the output unit. Here, we have the sensor output port on board as 7. |
GND |
This port is used to connect to the board's Grounded port. |
VCC |
The voltage supply port, here we have used the 5 V supply port from the board. |
Distance Manipulator |
The CW (Clock wise) movement increases the distance proximity and the opposite decreases. |
Power and Obstacle LED |
Former illuminates when the Power is supplied and the latter when any obstacle comes over. |
The circuit board looks as shown below:
The circuit diagram would look as shown below:
This is similar to the previous LED connection of my Arduino series. Series I
If the above is not clear, please share your query in the comments.
Snippet
- int LED = 13;
- int obstaclePin = 7;
- int hasObstacle = HIGH;
- void setup()
- {
- pinMode(LED, OUTPUT);
- pinMode(obstaclePin, INPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- hasObstacle = digitalRead(obstaclePin);
- if (hasObstacle == LOW)
- {
- Serial.println("Stop something is ahead!!");
- digitalWrite(LED, HIGH);
- } else
- {
- Serial.println("Path is clear");
- digitalWrite(LED, LOW);
- }
- delay(200);
- }
The Flow
When the full circuit is done the code set is also done. Now, it's the time to connect the board to the computer, using the USB jack. Suppose there is a COM3 port, open the Arduino Set up IDE, where the code set up is done, compile the code once and then upload the code to the board. Once the upload is done, the TX RX LED blinks quickly.
Now, we are all set to test the sensor. For better and precise testing, we can solder the wires (jumper wires) to the sensors as their connected pins are not portable. The whole set up can be soldered.
When we connect, open up the Serial port screen, which transmits at 9600 bits per second, and check the message, as written in the program.
As per the program, the LED also blinks and illuminates, based on the Obstacle sensor output.
The serial screen would look as shown below:
That's it folks!!
Conclusion
Now, this is all about the sensor IR Obstacle sensor, which you can purchase at a very cheap rate from Ebay or Amazon and play with. We can use this set up in our cars and check it out!! In the upcoming series, I will be sharing more sensors and Bluetooth module integrations with Arduino. I hope they will be more fun! Please share your experiences and suggestions as I am still crawling.