ARDUINO SENSORS
1) INFRARED SENSOR
IR (infrared) sensors detect infrared light. The IR light is transformed into an electric current, and this is detected by a voltage or amperage detector.A property of light-emitting diodes (LEDs) is that they produce a certain wavelength of light when an electric current is applied--but they also produce a current when they are subjected to the same wavelength light.
A pair of IR LEDs can be used as motion detectors. The first IR LED is wired to emit LED and the second LED is wired to transmit a signal when it receives an IR input. When an object comes within range of the emitted IR, it reflects the IR back to the receiving LED and produces a signal. This signal can be used to open sliding doors, turn on a light or set off an alarm
2)ULTRASONIC SENSOR
The energy transmitted by an ultrasonic sensor to an object comes in the form of ultrasound, which is a sound wave above what the human ear can perceive. Ultrasounds are generated by an ultrasonic transducer that transmits ultrasonic waves coming from mechanical energy produced by air blowing.
A basic ultrasonic sensor is composed of a transmitter and a receiver. There are two general types of ultrasonic sensors, differing only in the material used to generate the wave. The first is a piezoelectric sensor, which generates ultrasonic waves through piezoelectric quartz crystals or ceramics. The second is an electrostatic sensor, which makes use of a micro-thin metallic membrane.
Ultrasonic sensors can be used for detecting levels of liquid content in a tank or container. The sensor emits the wave towards the liquid surface, which bounces the wave back to the sensor receiver. The data is sent to a system to calculate the liquid level based on pre-programmed information about the tank's full level. More advanced uses of ultrasonic sensors are found in the field of medicine, particularly in medical ultrasonography, which is used to detect the fetus inside a mother's womb.
3) PIR MOTION SENSOR
PIR sensors are more complicated than many of the other sensors explained in these tutorials (like photocells,FSRs and tilt switches) because there are multiple variables that affect the sensors input and output. T
The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected
The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected
4)GAS SENSOR
The Analog CO/Combustible Gas Sensor(MQ9) module is useful for gas leakage detecting, it used the sensitive material SnO2, which with lower conductivity in clean air. It make detection by method of cycle high and low temperature, and detect CO when low temperature (heated by 1.5V). The sensors conductivity is more higher along with the gas concentration rising. When high temperature (heated by 5.0V), it detects Methane, Propane etc combustible gas and cleans the other gases adsorbed under low temperature. MQ-9 gas sensor has high sensitity to Carbon Monoxide, Methane and LPG. The sensor could be used to detect different gases contains CO and combustible gases, it is with low cost and suitable for different application.
5)TEMERATURE SENSOR
A temperature sensor measures temperature using four measurement scales that are divided into various degree units. The measurement scales use the metric Celsius scale, and they start at zero. The Rankin scale is the absolute scale that uses Fahrenheit temperature sensing. Temperature sensors determine absolute zero measurements as close to minus 460 degrees Fahrenheit. The Rankin scale measures absolute zero as 492 degrees Rankin.
A popular thermal measuring method is thermocouple, which is composed of two different metal alloy wires. Combining two different metals generates a strong voltage that has the same capacity as temperature. Thermocouples typically provide vast measurement ranges. They work using the Seebeck effect which involves changes in temperature in electrical circuits. The sensors read temperature by taking measurements of voltage outputs.
Thermistors are another type of temperature sensor, and they’re mostly used in human thermometers and appliances. Their predictable resistance reacts to temperature change. When temperature changes, the electrical current or resistance also changes.
Non-contact temperature sensors measure temperature without touching the object. They measure thermal radiation to determine temperature.
Test code for Sensor are given below;
1)Code for Infrared:
//NBSL COMMERCIAL
int LED = A4;
int obstaclePin = A5;
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);
delay(200);
}
else
{
Serial.println("Path is clear");
digitalWrite(LED, LOW);
}
delay(200);
}
2)Code for Ultrasonic Sensor:
//NBSL COMMERCIAL
#define trigPin 13
#define echoPin 12
#define led 11
#define led2 10
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 4) { // This is where the LED On/Off happens
digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off
digitalWrite(led2,LOW);
}
else {
digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
}
if (distance >= 200 || distance <= 0){
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" cm");
}
delay(500);
}
3)Code for Pir Motion Sensor:
//NBSL COMMERCIAL
int motion_1 = 2;
int light_1 = 13;
void setup(){
pinMode (motion_1,INPUT);
pinMode (light_1, OUTPUT);
}
void loop (){
digitalWrite (light_1,LOW);
delay(1000); //this delay is to let the sensor settle down before taking a reading
int sensor_1 = digitalRead(motion_1);
if (sensor_1 == HIGH){
digitalWrite(light_1,HIGH);
delay(500);
digitalWrite(light_1,LOW);
delay(500);
}
}
4)Code for Gas Sensor:
//NBSL COMMERCIAL
void setup() {
Serial.begin(9600);
}
void loop() {
float sensor_volt;
float RS_air; // Get the value of RS via in a clear air
float R0; // Get the value of R0 via in LPG
float sensorValue;
for(int x = 0 ; x < 100 ; x++)
{
sensorValue = sensorValue + analogRead(A0);
}
sensorValue = sensorValue/100.0;
sensor_volt = sensorValue/1024*5.0;
RS_air = (5.0-sensor_volt)/sensor_volt; // omit *RL
R0 = RS_air/9.9; // The ratio of RS/R0 is 9.9 in LPG gas
Serial.print("sensor_volt = ");
Serial.print(sensor_volt);
Serial.println("V");
Serial.print("R0 = ");
Serial.println(R0);
delay(1000);
}
5)Code for Temperature Sensor:
//NBSL COMMERCIAL
int sensorPin = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
Serial.print(voltage); Serial.println(" volts");
float temperatureC = (voltage - 0.5) * 100 ;
Serial.print(temperatureC); Serial.println(" degrees C");
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
delay(1000);
}
//NBSL COMMERCIAL
int LED = A4;
int obstaclePin = A5;
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);
delay(200);
}
else
{
Serial.println("Path is clear");
digitalWrite(LED, LOW);
}
delay(200);
}
2)Code for Ultrasonic Sensor:
//NBSL COMMERCIAL
#define trigPin 13
#define echoPin 12
#define led 11
#define led2 10
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 4) { // This is where the LED On/Off happens
digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off
digitalWrite(led2,LOW);
}
else {
digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
}
if (distance >= 200 || distance <= 0){
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" cm");
}
delay(500);
}
3)Code for Pir Motion Sensor:
//NBSL COMMERCIAL
int motion_1 = 2;
int light_1 = 13;
void setup(){
pinMode (motion_1,INPUT);
pinMode (light_1, OUTPUT);
}
void loop (){
digitalWrite (light_1,LOW);
delay(1000); //this delay is to let the sensor settle down before taking a reading
int sensor_1 = digitalRead(motion_1);
if (sensor_1 == HIGH){
digitalWrite(light_1,HIGH);
delay(500);
digitalWrite(light_1,LOW);
delay(500);
}
}
4)Code for Gas Sensor:
//NBSL COMMERCIAL
void setup() {
Serial.begin(9600);
}
void loop() {
float sensor_volt;
float RS_air; // Get the value of RS via in a clear air
float R0; // Get the value of R0 via in LPG
float sensorValue;
for(int x = 0 ; x < 100 ; x++)
{
sensorValue = sensorValue + analogRead(A0);
}
sensorValue = sensorValue/100.0;
sensor_volt = sensorValue/1024*5.0;
RS_air = (5.0-sensor_volt)/sensor_volt; // omit *RL
R0 = RS_air/9.9; // The ratio of RS/R0 is 9.9 in LPG gas
Serial.print("sensor_volt = ");
Serial.print(sensor_volt);
Serial.println("V");
Serial.print("R0 = ");
Serial.println(R0);
delay(1000);
}
5)Code for Temperature Sensor:
//NBSL COMMERCIAL
int sensorPin = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
Serial.print(voltage); Serial.println(" volts");
float temperatureC = (voltage - 0.5) * 100 ;
Serial.print(temperatureC); Serial.println(" degrees C");
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
delay(1000);
}
View of Arduino sensors;
This comment has been removed by a blog administrator.
ReplyDelete