The infrared obstacle avoidance sensor module (short for avoidance module) returns a signal when it detects an object in range. The sensor can detect a distance from 2 up to 40 cm. The module operates at 3.5 to 5 volts, and the working current is 20mA. There are 4 pins on this module, namely: the GND, "+", OUT and EN pins. The GND pin should be connected to the GND pin of Arduino, The "+" (VCC) pin should be connected to 5V pin of Arduino, the OUT (signal) pin should be connected to any digital pin of Arduino, and the EN (Enable) pin should be connected to any digital pin of Arduino. The application of this module is typically used mostly to a wheeled robot, where it avoid obstacles with the use of this sensor module. The sensor detects the distance of an object based on the adjustable distance settings. The module has an infrared transmitter and receiver on board. The transmitter LED emits a certain frequency of infrared, in which the receiver LED will detect the signal from emitter and will trigger the digital on/off "signal" pin when a specific threshold "distance" has been detected. The module has two potentiometers. The potentiometer with the S02 label is for adjustment of trasmitter IR frequency, and the potentiometer with the E01 label is for adjustment of the distance from the object at which the sensor detects it. The function of this module is almost similar with the line tracking module functionality. In the given code below, when the obstacle sensor detects signal, the LED flashes. Code example for Avoidance Sensor Module
Upload the code to Arduino. Once uploaded, you may test the module by putting closer to a certain object (like wall, desk, etc.). Observe if the LED will change the display.
The line tracking sensor module (or sometimes called the hunt sensor module or line tracing sensor module ) detects if a light reflecting or absorbing area is in front of it. The sensor has a pair of infrared transmitter and receiver. The transmitter emits a certain frequency of infrared ray. If the light is reflecting, the module generates a LOW value (from 0 to 499 values). If the light is not reflecting back to the IR Led receiver, the module generates a HIGH value (from 500 up to 1023 values). The usual color to be used here is black and white color. Use black color (absorbing) for producing HIGH value by the line tracking sensor module, and use white color (reflecting) for producing LOW value by the module. The module has the potentiometer where it can be adjusted to change the distance settings. Connection The GND pin of the module should be connected to the GND pin of Arduino, the VCC should be connected to 5V of Arduino, and the OUT pin (or signal pin) should be connected to analog pin or digital pin. Code Example Let us see the code example below using the digital pin in Arduino. In the code, if the light of the line tracking sensor did not return, or the light has been absorbed by the object in front of it, the module will produce a HIGH value. If the light from the sensor reflects because of the bright color of the object in front of it, it will produce a LOW value. Line Tracking Sensor code example using digital pin
Code Example Let us see the code example below using the analog pin in Arduino. In the code, if the light of the line tracking sensor did not return, or the light has been absorbed by the object in front of it, using the analogRead() function, the module will produce a big value ranging from 500 up to 1023. If the light from the sensor reflects because of the bright color of the object in front of it, it will produce a small value ranging from 0 to 499. Line Tracking Sensor code example - Analog pin
The line tracking sensor is typically used for movable robots or cars for tracking a specific line drawn on the floor using the black color.
A Tilt sensor is a switch device that detects the change of orientation of an object and gives its output High or Low signal. The mercury tilt switch module uses a small mercury ball that open or close the circuit when you tilt the module. The output is HIGH when the mercury ball closes the circuit, and LOW when the mercury is placed away from the circuit Module Specifications This module consists of a mercury switch, a 680 ohm resistor and an LED that will light up when tilt is detected. The mercury ball will open or close the circuit when the module is rotated or tilted. It has 3 pins, namely: signal (S), VCC and the GND. The signal pin should be connected to any digital pin of arduino. The VCC pin will be connected to the 5V of Arduino and the GND pin will be connected to the GND of the Arduino. See below for the code example to test the Mercury Tilt Switch module Upload and test the code in Arduino. The light on of led will turn on when the module is tilted. Enjoy tilting!
The Knock Switch Sensor Module (also known as Tap Module) is a mechanical sensor that detects knock or tap or vibration. It is almost the same behavior with our previous article using the Shock Switch Module. The only difference is that you have to apply more pressure or knock the module to trigger the desired output. The default desired output is LOW level (same with Shock Switch Module). This mechanical knock sensor in the module contains a coiled spring in a clear plastic housing and a pull-up resistor. Note: If you want to reverse the desired output, from LOW level to HIGH level, you just interchange the connection of the GND and the power line (middle pin).
Code example for Knock Sensor Module
Upload the code to Arduino and test the knock sensor module. Tap harder. Once it detects the impact, the LED will turn on.
A key switch module is a push button device that would provide an output HIGH signal when the button has been pressed. The module contains a tactile push button switch and a resistor.
Upload the code and test the module. The LED should turned on when the button has been pressed, and turned off when it is not pressed.
|