Arduino Peripheral Modules: Sensor components (thermo-sensitive, photosensitive, wet-sensitive)

Source: Internet
Author: User

<title>Arduino Peripheral Modules: Sensor components (thermo-sensitive, photosensitive, wet-sensitive)</title> Arduino Peripheral Modules: analog-to-digital conversion of sensor components (thermo-sensitive, photosensitive, wet-sensitive) Arduino

For Arduino, it only knows digital, and the analogue is a "foreign language".
Analog: Both time and value are continuous physical quantities.
Digital quantity: Both time and value are discrete physical quantities.
The analog-to-digital conversion circuit is capable of converting analogue quantities to numbers.

Analog-to-digital conversion principle:
    1. Discrete in time--sampling

      At a certain time, the size of the analog volume is collected. The higher the frequency of sampling, the better the analog-to-digital conversion effect. The frequency of general sampling is more than twice times of the signal frequency.
    2. Discrete in numerical--quantization and coding
      Example: 3-bit precision analog-to-digital converters
Analog-to-digital converters in Arduino


Arduino analog-to-digital conversion library functions:
analogReference()
analogRead()

Instance:
1.void Setup ()
2. {
3.Serial.begin (9600);//Initialize the serial number
4.}
5. void loop()
6. {
7. intSensorvalue=analogread (A0);
8.Serial.println (Sensorvalue);//Output value
9.Delay -);//Delay
.}

After clicking Upload to Arduino, you can view the values read by the sensor in Tools–>serial Monitor.

Sensor is a kind of detection device, can feel the information that is measured, and can feel the information, according to certain laws to transform into electrical signals or other required forms of information output, to meet the information transmission, processing, storage, display, recording and control requirements.
Sensor classification: Thermal, photosensitive, sound-sensitive, gas-sensitive, chemical, sensitive operational, magnetic-sensitive, wet-sensitive, color-sensitive, taste-sensitive

Monitor room temperature with Arduino

Thermal sensors (temperature sensors): devices that convert temperature information into electrical signals

General use lm35d

Parameters:
Temperature range: 0~100℃
Temperature measurement accuracy: 0.5 ℃
Operating voltage: 4~30v

The principle of temperature measurement: converting temperatures to equal proportional voltage output
Output 0V at 0 ℃. The output voltage is increased by 10mV for every 1 ℃ temperature increase

Connection:

Temperature sensor and Arduino connection diagram

Arduino temperature Monitoring System Connection diagram

Code:
1.#include <LiquidCrystal.h> 
2.liquidcrystal LCD(5,4,3,2) ;
3.intsensorpin=a0;
4. float gettemperature()
5. {
6. floatVoltage=analogread (Sensorpin)/1024.0*5;
7. floattemperature=voltage/0.01;
8. returntemperature;
9.}
.
One by one . void setup()
. {
.Lcd.begin ( -,2);//Initialize LCD1602
.}
A .void Loop ()
. {
.Lcd.clear ();
.Lcd.print ("Temperature is");
.Lcd.setcursor (0,1);
.Lcd.print (Gettemperature ());
.Delay -);
.}
Using Arduino to detect indoor light intensity

Photosensitive sensor: Photoresistors is a resistor made from the photoelectric effect of a semiconductor that changes with the intensity of the incident light, the incident light is strong, the resistance decreases, the incident light is weak, and the resistance increases.

Light intensity measurement Circuit

Hardware connection
Realization function: Led is lit when light is weak, led goes out when light is strong.

Program writing

1. void setup()
2. {
3.Serial.begin (9600);
4.}
5. void loop()
6. {
7. intSensorvalue=analogread (A0);
8.Serial.println (Sensorvalue);
9.Delay -);
.}

Then the light sensor is blocked by hand, and when the hand is blocked, the value read back is greater than 950.

1.intledpin=6;
2. void setup()
3. {
4.Pinmode (Ledpin,output);
5.Serial.begin (9600);
6.}
7.void Loop ()
8. {
9. intSensorvalue=analogread (A0);
.Serial.println (Sensorvalue);
One by one . if(sensorvalue>950)
.{
.Digitalwrite (Ledpin,high);
.}Else
A .{
.Digitalwrite (Ledpin,low);
.}
.Delay -);
.}
Using Arduino to detect humidity

Humidity sensor: The substrate is covered with a layer of moisture-sensitive material made of film, when the air vapor adsorption on the wet-sensing film, the components of the resistivity and resistance values are changed, using this feature can measure the humidity.

Similar to light sensor connection
Program:

1.void Setup ()
2. {
3.Serial.begin (9600);
4.}
5. void loop()
6. {
7. intSensorvalue=analogread (A0);
8.Serial.println (Sensorvalue);
9.Delay -);
.}

After running the program read the data are more than 1000, the sensor into the water, the readings are less than 100, so we have to adjust the humidity according to their own needs. Take 200 here.

1.LED ledpin=6;
2. void setup()
3. {
4.Pinmode (Ledpin,output);
5.Serial.begin (9600);
6.}
7. void loop()
8. {
9. intSensorvalue=analogread (A0);
.Serial.println (Sensorvalue);
One by one . if(sensorvalue> $)
.{
.Digitalwrite (Ledpin,high);
.}
A .Delay -);
.Digitalwrite (Ledpin,low);
.}

Arduino Peripheral Modules: Sensor components (thermo-sensitive, photosensitive, wet-sensitive)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.