Ks0068 keyestudio 37 in 1 Sensor Kit for Arduino Starters: Difference between revisions
Keyestudio (talk | contribs) |
Keyestudio (talk | contribs) |
||
(85 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
==kesestudio 37 in 1 Sensor Kit for Arduino Starters== | ==kesestudio 37 in 1 Sensor Kit for Arduino Starters== | ||
[[File: | [[File:KS0068_(13).jpg|500px|frameless|thumb]] | ||
* Sensor kit for Arduino <br> | * Sensor kit for Arduino <br> | ||
* Based on open-source hardware <br> | * Based on open-source hardware <br> | ||
Line 9: | Line 10: | ||
<br> | <br> | ||
=='''Summary''' == | =='''Summary''' == | ||
This is keyestudio sensor learning kit. We bring together 37 basic sensors and modules, aiming for the convenient learning for starters. | This is keyestudio sensor learning kit. We bring together 37 basic sensors and modules, aiming for the convenient learning for starters. | ||
Line 16: | Line 18: | ||
The working principle is pretty much the same. <br> | The working principle is pretty much the same. <br> | ||
Now, let us embrace this fascinating world of ARDUINO and learn together! | Now, let us embrace this fascinating world of ARDUINO and learn together! | ||
<br>[[File: | <br>[[File:KS0068 (6).jpg|600px|frameless|thumb]]<br> | ||
=='''Project Details''' == | =='''Project Details''' == | ||
<br> | <br> | ||
=== Project 1: LED Light | === '''Project 1: White LED Light ''' === | ||
<br> | <br> | ||
'''Introduction''' <br> | '''Introduction''' <br> | ||
Line 31: | Line 33: | ||
<br> | <br> | ||
'''Features''' <br> | '''Features''' <br> | ||
* Control interface: Digital | * Control interface: Digital | ||
Line 41: | Line 42: | ||
<br> | <br> | ||
'''Connect It Up'''<br> | |||
Connect the LED module to control board using three jumper wires. Then connect the control board to your PC with a USB cable.<br> | Connect the LED module to control board using three jumper wires. Then connect the control board to your PC with a USB cable.<br> | ||
<br>[[File:Ks0016-2.png|600px|frameless|thumb]]<br> | <br>[[File:Ks0016-2.png|600px|frameless|thumb]]<br> | ||
<br> | <br> | ||
'''Upload the Code'''<br> | |||
Copy and paste below code to Arduino IDE and upload. | |||
Copy and paste below code to Arduino IDE and upload. | |||
<pre> | <pre> | ||
int led = 7; | int led = 7; | ||
Line 65: | Line 65: | ||
<br> | <br> | ||
'''Test Result'''<br> | |||
The LED will flash on for one second, then off for one second, repeatedly and alternately. <br> | The LED will flash on for one second, then off for one second, repeatedly and alternately. <br> | ||
If it doesn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board. <br> | If it doesn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board. <br> | ||
<br>[[File:Ks0017.png|600px|frameless|thumb]]<br> | <br>[[File:Ks0017.png|600px|frameless|thumb]]<br> | ||
<br> | |||
'''Introduction | === '''Project 2: Red LED Light '''=== | ||
This is a | <br> | ||
'''Introduction''' <br> | |||
This is a red LED module. The main function is to control a plugin LED on and off. When connecting to ARDUINO, after programming, it will emit red light color.<br> | |||
The pin pitch of 3Pin is 2.54mm. | |||
This LED module has 3 Pins; - pin is connected to ground, + pin is connected to VCC(3.3-5V), S pin is for signal control; you can set the High or Low level to control the LED on and off. <br> | |||
You can combine with other sensors to do various interactive experiments. <br> | |||
You can also choose other LED modules to emit different light color like blue, green, yellow and white.<br> | |||
<br>[[File:Ks0232-1.png|350px|frameless|thumb]]<br> | |||
''' | <br> | ||
* | '''Features''' <br> | ||
*Working voltage: | * Control interface: Digital | ||
* | * Working voltage: DC 3.3-5V | ||
* | * Pin pitch: 2.54mm | ||
* | * LED color: red | ||
* Easy to use | |||
* Useful for light projects | |||
<br> | |||
'''Technical Details''' <br> | |||
* Dimensions: 34mm*20mm*11.5mm | |||
* Weight: 2.7g | |||
''' | <br> | ||
<br>[[File: | '''Connect It Up''' <br> | ||
Connect the red LED module to control board using three jumper wires. Then connect the control board to your PC with a USB cable.<br> | |||
<br>[[File:Ks0232-2.png|600px|frameless|thumb]]<br> | |||
<br> | |||
'''Upload the Code''' <br> | |||
Copy and paste below code to Arduino IDE and upload. <br> | |||
<pre> | <pre> | ||
int led = 7; | |||
int led = | |||
void setup() | void setup() | ||
{ | { | ||
pinMode(led, OUTPUT); //Set | pinMode(led, OUTPUT); //Set Pin7 as output | ||
} | } | ||
void loop() | void loop() | ||
{ | { digitalWrite(led, HIGH); //Turn off led | ||
delay( | delay(1000); | ||
digitalWrite(led, LOW); //Turn on led | digitalWrite(led, LOW); //Turn on led | ||
delay( | delay(1000); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Test Result'''<br> | |||
The LED will flash on for one second, then off for one second, repeatedly and alternately. <br> | |||
If it doesn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board. <br> | |||
<br>[[File:Ks0232-3.png|500px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 3: 3W LED Module '''=== | === '''Project 3: 3W LED Module '''=== | ||
<br>[[File: | <br> | ||
'''Introduction'''<br> | |||
This LED module is of high brightness because the lamp beads it carries is 3W. We can apply this module to Arduino projects. <br> | |||
For example, intelligent robots can use this module for illumination purpose.<br> | |||
Please note that the LED light can't be exposed directly to human eyes for safety concerns. | |||
<br>[[File:KS0010 (4).jpg|500px|frameless|thumb]]<br> | |||
''' | <br> | ||
'''Specification'''<br> | |||
* Color temperature: 6000~7000K | |||
* Luminous flux: 180~210lm | |||
* Current: 700~750mA | |||
* IO Type: Digital | |||
* Supply Voltage: 3.3V to 5V | |||
* Power: 3W | |||
* Light angle: 140 degree | |||
* Working temperature: -50~80℃ | |||
* Storage temperature: -50~100℃ | |||
* High power LED module, controlled by IO port microcontroller | |||
* Great for Robot and search & rescue platform application | |||
''' | <br> | ||
'''Connection Diagram''' | |||
<br>[[File:Ks0010.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' <br> | |||
<pre> | <pre> | ||
// the setup function runs once when you press reset or power the board | // the setup function runs once when you press reset or power the board | ||
void setup() { | void setup() { | ||
Line 148: | Line 168: | ||
delay(1000); // wait for a second | delay(1000); // wait for a second | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result'''<br> | |||
Done wiring and powered up,upload well the code, both D13 led and the led on the module blink for one second then off, circularly. | |||
<br>[[File:KS0349 3-2.png|800px|frameless|thumb]]<br> | |||
<br> | |||
'''Introduction | <br> | ||
This is a full-color LED module, which contains 3 basic colors-red, green and blue. They can be seen as separate LED lights. After | === '''Project 4: RGB LED '''=== | ||
'''Introduction''' <br> | |||
This is a full-color LED module, which contains 3 basic colors-red, green and blue. They can be seen as separate LED lights. <br> | |||
After programming, you can turn them on and off by sequence or can also use PWM analog output to mix three colors to generate different colors. | |||
<br>[[File:Ks0032-3.png|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Color: red, green and blue | *Color: red, green and blue | ||
*Brightness: High | *Brightness: High | ||
*Voltage: 5V | *Voltage: 5V | ||
*Input: digital level | *Input: digital level | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:0032.jpg|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' <br> | |||
<pre> | <pre> | ||
int redpin = 11; //select the pin for the red LED | int redpin = 11; //select the pin for the red LED | ||
int bluepin =10; // select the pin for the blue LED | int bluepin =10; // select the pin for the blue LED | ||
Line 194: | Line 220: | ||
analogWrite(9, 128-val); | analogWrite(9, 128-val); | ||
delay(1); | delay(1); | ||
} | |||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Done uploading the code, you should see the RGB LED flashing with different colors. | |||
<br>[[File:Ks0032-1.png|500px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 5: Analog Temperature | === '''Project 5: Analog Temperature '''=== | ||
<br>[[File: | <br> | ||
'''Introduction'''<br> | |||
This module is based on the working principle of a thermistor (resistance varies with temperature change in the environment). <br> | |||
It can sense temperature change in its surrounding and send the data to the analog IO in the Arduino board. <br> | |||
All we need to do is to convert the sensor output data into degrees Celsius temperature via simple programming, finally to display it. <br> | |||
It's both convenient and effective, thus it is widely applied in gardening, home alarm system and other devices. | |||
<br>[[File:Ks0033.png|500px|frameless|thumb]]<br> | |||
''' | <br> | ||
'''Specification'''<br> | |||
*Interface Type: analog | |||
*Working Voltage: 5V | |||
*Temperature Range: -55℃~315℃ | |||
''' | <br> | ||
'''Connection Diagram''' <br> | |||
<br>[[File:Ks0033-.png|700px|frameless|thumb]]<br> | |||
''' | <br> | ||
'''Sample Code'''<br> | |||
Copy and paste the below code to Arduino software. | |||
<pre> | <pre> | ||
void setup() | void setup() | ||
Line 228: | Line 265: | ||
</pre> | </pre> | ||
The above code is only for analog value. | <br> | ||
You can see that the analog value is changing according to the temperature change in the environment. But it’s not very obvious. | The above code is only for analog value. <br> | ||
Let’s solve this by using the following equation. Then upload the code below to the Arduino board. The value read from the serial port is similar to normal temperature. | You can see that the analog value is changing according to the temperature change in the environment. But it’s not very obvious.<br> | ||
Let’s solve this by using the following equation. Then upload the code below to the Arduino board. The value read from the serial port is similar to normal temperature. <br> | |||
e.g. The temperature right now is 30°C. <br> | |||
<pre> | <pre> | ||
Line 248: | Line 287: | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' | |||
<br>[[File:KS0349 19-2.png|800px|frameless|thumb]]<br> | |||
Done wiring and powered up, upload well the code, then open the serial monitor, you will see the current temperature value. Shown below. | |||
<br>[[File:KS0349 19-3.png|900px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 6: Photocell Sensor '''=== | === '''Project 6: Photocell Sensor '''=== | ||
<br>[[File:KS0349 21-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 21-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
Photocell is commonly seen in our daily life and is mainly used in intelligent switch, also in common electronic design. To make it easier and | Photocell is commonly seen in our daily life and is mainly used in intelligent switch, also in common electronic design. <br> | ||
Photocell is a semiconductor. It has features of high sensitivity, quick response, spectral characteristic, and R-value consistence, maintaining high stability and reliability in environment extremes such as high temperature, high humidity. It’s widely used in automatic control switch fields like cameras, garden solar lights, lawn lamps, money detectors, quartz clocks, music cups, gift boxes, mini night lights, sound and light control switches, etc. | To make it more easier and effective, we supply corresponding modules. | ||
Photocell is a semiconductor. It has features of high sensitivity, quick response, spectral characteristic, and R-value consistence, maintaining high stability and reliability in environment extremes such as high temperature, high humidity. <br> | |||
It’s widely used in automatic control switch fields like cameras, garden solar lights, lawn lamps, money detectors, quartz clocks, music cups, gift boxes, mini night lights, sound and light control switches, etc. | |||
'''Specification | <br> | ||
*Interface | '''Specification'''<br> | ||
*Working | *Interface Type: analog | ||
*Working Voltage: 5V | |||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0028.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int sensorPin =A0 ; | int sensorPin =A0 ; | ||
int value = 0; | int value = 0; | ||
Line 277: | Line 324: | ||
{ | { | ||
value = analogRead(sensorPin); | value = analogRead(sensorPin); | ||
Serial.println(value, DEC); | Serial.println(value, DEC); | ||
delay(50); } | delay(50); | ||
} | |||
</pre> | </pre> | ||
<br> | |||
'''Result''' | |||
<br>[[File:KS0349 21-2.png|800px|frameless|thumb]]<br> | |||
Done wiring and powered up, upload well the code, then open the serial monitor, if cover the photocell on the sensor with your hand, you will see the analog value decrease. Shown as below. | |||
<br>[[File:KS0349 21-3.png|1000px|frameless|thumb]]<br> | |||
=== '''Project 7: Analog Sound | <br> | ||
<br>[[File: | === '''Project 7: Analog Sound '''=== | ||
<br> | |||
'''Introduction'''<br> | |||
The keyestudio microphone sensor is typically used in detecting the loudness in ambient environment. The Arduino can collect its output signal by analog input interface. <br> | |||
The S pin is analog output, that is voltage signal real-time output of microphone. The sensor comes with a potentiometer, so that you can turn it to adjust the signal gain.<br> | |||
It also has a fixed hole so that you can mount the sensor on any other devices. | |||
You can use it to make some interactive works, such as a voice operated switch. | |||
<br>[[File:Ks0035(1).png|400px|frameless|thumb]]<br> | |||
''' | <br> | ||
'''Specification'''<br> | |||
* Operating voltage: 3.3V-5V(DC) | |||
* Operating current: <10mA | |||
* Interface:3PIN | |||
* Output signal: Analog | |||
<br> | |||
'''Connection Diagram''' <br> | |||
<br>[[File:Ks0035(2).png|700px|frameless|thumb]]<br> | |||
'''Connection Diagram | |||
<br>[[File: | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int sensorPin =A0 ; // define analog port A0 | |||
void setup() | int value = 0; //set value to 0 | ||
void setup() | |||
{ | { | ||
Serial.begin(9600); //set the baud rate to 9600 | |||
} | } | ||
void loop() | void loop() | ||
{ | { | ||
value = analogRead(sensorPin); //set the value as the value read from A0 | |||
Serial.println(value, DEC); //print the value and line wrap | |||
delay(200); //delay 0.2S | |||
} | |||
} | </pre> | ||
<br> | |||
< | '''Test Result''' <br> | ||
Connect it up and upload the code successfully, then open the serial monitor on the right upper corner of Arduino IDE. | |||
<br> | |||
The analog value will pop up on the monitor window. The greater the sound, the greater the analog value is. | |||
<br>[[File:Ks0035(3).png|700px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 8: Analog Rotation Sensor '''=== | === '''Project 8: Analog Rotation Sensor '''=== | ||
<br>[[File:KS0349 20-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 20-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | <br> | ||
This analog Rotation Sensor is arduino compatible. It is based on a potentiometer. Its voltage can be subdivided into 1024, easy to be connected to Arduino with our sensor shield. Combined with other sensors, we can make interesting projects by reading the analog value from the IO port. | '''Introduction'''<br> | ||
This analog Rotation Sensor is arduino compatible. It is based on a potentiometer. Its voltage can be subdivided into 1024, easy to be connected to Arduino with our sensor shield. Combined with other sensors, we can make interesting projects by reading the analog value from the IO port. | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
*Interface: Analog | *Interface: Analog | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0014.png|600px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' | |||
<pre> | <pre> | ||
void setup() | void setup() | ||
{ | { | ||
Line 353: | Line 414: | ||
delay(100); | delay(100); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' | |||
<br>[[File:KS0349 20-2.png|800px|frameless|thumb]]<br> | |||
Done wiring and powered up, upload well the above code, then open the serial monitor and set the baud rate as 9600, finally you will see the analog value. If rotate the knob on the rotation sensor, the value will be changed within 0-1023. Shown below. | |||
<br>[[File:KS0349 20-3.png|800px|frameless|thumb]]<br> | |||
<br> | |||
''' | === '''Project 9: Passive Buzzer '''=== | ||
[[File:KS0019 (4).jpg|300px|frameless|right]] | |||
''' | '''Introduction'''<br> | ||
We can use Arduino to make many interactive works of which the most commonly used is acoustic-optic display. <br> | |||
The circuit in this experiment can produce sound. Normally, the experiment is done with a buzzer or a speaker while buzzer is simpler and easier to use. <br> | |||
The buzzer we introduced here is a passive buzzer. It cannot be actuated by itself, but by external pulse frequencies. Different frequencies produce different sounds. <br> | |||
We can use Arduino to code the melody of a song, which is quite fun and simple. | |||
''' | <br> | ||
'''Specification'''<br> | |||
* Working voltage: 3.3-5v | |||
* Interface type: digital | |||
''' | <br> | ||
'''Connection Diagram''' | |||
<br>[[File:0019.png|600px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int buzzer=3;//set digital IO pin of the buzzer | |||
int buzzer= | |||
void setup() | void setup() | ||
{ | { | ||
Line 394: | Line 463: | ||
digitalWrite(buzzer,HIGH);// sound | digitalWrite(buzzer,HIGH);// sound | ||
digitalWrite(buzzer,LOW);//not sound | digitalWrite(buzzer,LOW);//not sound | ||
delay(2);//2ms delay | delay(2);//2ms delay | ||
} | |||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Test Result'''<br> | |||
After downloading the program, buzzer experiment is complete. You should hear the buzzer ringing. | |||
<br>[[File:Ks0019-1-.png|600px|frameless|thumb]]<br> | |||
<br> | |||
''' | === '''Project 10: Digital Buzzer '''=== | ||
<br> | |||
'''Introduction'''<br> | |||
Here is the simplest sound making module. You can use high/low level to drive it. Changing the frequency it buzzes can produce different sound. This module is widely used on your daily appliance, like PC, refrigerator, phones etc. And you can also create many interesting interactive project with this small but useful module. | |||
Just try it!! You will find the electronic sound it creates so fascinating. | |||
<br>[[File:KS0349 5-1.png|500px|frameless|thumb]]<br> | |||
''' | <br> | ||
'''Specification'''<br> | |||
*Working Voltage: 3.3-5v | |||
*Interface Type: digital | |||
''' | <br> | ||
'''Connection Diagram''' | |||
<br>[[File:Ks0018-.png|600px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int buzzPin = 3; //Connect Buzzer on Digital Pin3 | int buzzPin = 3; //Connect Buzzer on Digital Pin3 | ||
void setup() | void setup() | ||
Line 436: | Line 508: | ||
delay(1); | delay(1); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Test Result''' <br> | |||
After uploading the code, you can hear the buzzer beep continually. | |||
<br>[[File:Ks0018-1.png|600px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 11: Digital Push Button '''=== | === '''Project 11: Digital Push Button '''=== | ||
<br>[[File: | <br> | ||
'''Introduction'''<br> | |||
This is a basic button application module. Momentary Pushbutton Switch usually stays open. When it is pressed down, circuit connected; when it is released, it will bounce back to the status of disconnection. | |||
The module has three pins for easy connection. You can simply plug it into an IO shield to have your first try of Arduino. | |||
<br>[[File:Ks0029-.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Details'''<br> | |||
* Interface: Digital | |||
* Supply Voltage: 3.3V to 5V | |||
* Easy to plug and operate | |||
* Large button keypad and high-quality button cap | |||
* Standard assembling structure | |||
* Easily recognizable pins | |||
* Icons illustrate sensor function clearly | |||
* Achieve interactive works | |||
''' | |||
*Supply Voltage: 3.3V to 5V | |||
*Easy to | |||
*Large button keypad and high-quality | |||
* | |||
* | |||
* | |||
* | |||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0029.png|700px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' | |||
<pre> | <pre> | ||
/* # When you push the digital button, the Led 13 on the board will turn on. Otherwise,the led turns off. | /* # When you push the digital button, the Led 13 on the board will turn on. Otherwise,the led turns off. | ||
*/ | */ | ||
Line 483: | Line 557: | ||
digitalWrite(ledPin, HIGH); // turn LED ON | digitalWrite(ledPin, HIGH); // turn LED ON | ||
} | } | ||
} | |||
</pre> | </pre> | ||
<br> | |||
'''Result'''<br> | |||
When you push the digital button, the Led 13 on UNO board will be on. When release the button,the led is off. Shown as below. | |||
<br>[[File:KS0349 7-3.png|800px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 12: Digital Tilt Sensor '''=== | === '''Project 12: Digital Tilt Sensor '''=== | ||
'''Introduction | '''Introduction'''<br> | ||
Tilt | Tilt sensor is a digital tilt switch. It can be used as a simple tilt sensor. | ||
Tilt sensors (tilt ball switch) allow you to detect orientation or inclination. They are small, inexpensive, low-power and easy-to-use. | |||
'''Specification | Simply connect the sensor to our IO/Sensor shield, so you can make amazing interactive projects. | ||
[[File:KS0025 (3).jpg|500px|frameless|thumb]] | |||
<br> | |||
'''Specification'''<br> | |||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
*Interface: Digital | *Interface: Digital | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0025.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int ledPin = 13; // Connect LED to pin 13 | int ledPin = 13; // Connect LED to pin 13 | ||
int switcher = 3; // Connect Tilt sensor to Pin3 | int switcher = 3; // Connect Tilt sensor to Pin3 | ||
Line 527: | Line 605: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Upload the code to the board. Then tilt the sensor, you will see the led on the sensor is turned on. Shown as below. | |||
<br>[[File:KS0349 14-3.png|800px|frameless|thumb]]<br> | |||
=== '''Project 13: Photo | <br> | ||
=== '''Project 13: Photo Interrupter '''=== | |||
<br>[[File:KS0349 11-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 11-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
Upright part of this sensor is an infrared emitter and on the other side, it’s a shielded infrared detector. By emitting a beam of infrared light from one end to other end, the sensor can detect an object when it passes through the beam. It is used for many applications including optical limit switches, pellet dispensing, general object detection, etc. | Upright part of this sensor is an infrared emitter and on the other side, it’s a shielded infrared detector. By emitting a beam of infrared light from one end to other end, the sensor can detect an object when it passes through the beam. It is used for many applications including optical limit switches, pellet dispensing, general object detection, etc. | ||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
*Interface: Digital | *Interface: Digital | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0009.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
// photo interrupter module | // photo interrupter module | ||
Line 572: | Line 654: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
=== '''Project 14: Capacitive Touch | === '''Project 14: Capacitive Touch '''=== | ||
<br>[[File:KS0349 15-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 15-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
Are you tired of clicking mechanic button? Well, try our capacitive touch sensor. | Are you tired of clicking mechanic button? Well, try our capacitive touch sensor. You can find touch sensors mostly used on electronic device. So upgrade your Arduino project with our new version touch sensor and make it cool!!<br> | ||
This little sensor can "feel" people and metal touch and feedback a high/low voltage level. Even isolated by some cloth and paper, it can still feel the touch. Its | This little sensor can "feel" people and metal touch and feedback a high/low voltage level. Even isolated by some cloth and paper, it can still feel the touch. Its sensitivity decreases as isolation layer gets thicker. | ||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
*Interface: Digital | *Interface: Digital | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0031-1.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int ledPin = 13; // Connect LED on pin 13, or use the onboard one | int ledPin = 13; // Connect LED on pin 13, or use the onboard one | ||
int KEY = 2; // Connect Touch sensor on Digital Pin 2 | int KEY = 2; // Connect Touch sensor on Digital Pin 2 | ||
Line 612: | Line 692: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Done wiring and powered up, upload well the code, then touch the sensor with your finger, both D2 led on the sensor and D13 indicator on UNO board are on. Otherwise, those two indicators are turned off. | |||
<br>[[File:Ks0031-2.png|800px|frameless|thumb]]<br> | |||
=== '''Project 15: Knock | <br> | ||
<br>[[File: | === '''Project 15: Knock Module '''=== | ||
This is a knock sensor module. When you knock it, it can send a momentary signal. You can combine it with Arduino to make some interesting experiment, e.g. electronic drum. | |||
* Working voltage: 5V | |||
<br>[[File:Ks0024.png|400px|frameless|thumb]]<br> | |||
<br> | |||
'''Connection Diagram''' | |||
<br>[[File:Ks0024-.png|700px|frameless|thumb]]<br> | |||
'''Connection Diagram | |||
<br>[[File: | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int Led=13;//define LED interface | int Led=13;//define LED interface | ||
int Shock=3//define knock sensor interface | int Shock=3;//define knock sensor interface | ||
int val;//define digital variable val | |||
void setup() | void setup() | ||
{ | { | ||
Line 655: | Line 732: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Upload the code to the board. When the sensor detects a knock signal, both the led on the sensor and led 13 on the UNO board are turned on. | |||
<br> | |||
'''Extension'''<br> | |||
You can extend to connect an external LED; when knock the sensor, the external LED will turn on. For example:<br> | |||
<br>[[File:图片-KS0024.png|500px|frameless|thumb]]<br> | |||
<br> | |||
<br> | |||
=== '''Project 16: Hall Magnetic Sensor '''=== | === '''Project 16: Hall Magnetic Sensor '''=== | ||
'''Introduction | '''Introduction'''<br> | ||
This is a Magnetic Induction Sensor. It senses the magnetic materials within a detection range up to 3cm. The detection range and the strength of the magnetic field are proportional. The output is digital on/off. This sensor uses the SFE Reed Switch - Magnetic Field Sensor. <br> | This is a Magnetic Induction Sensor. It senses the magnetic materials within a detection range up to 3cm. The detection range and the strength of the magnetic field are proportional.The output is digital on/off. | ||
This sensor uses the SFE Reed Switch - Magnetic Field Sensor.<br> | |||
<br>[[File:KS0020 (2).jpg|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
*Sensing magnetic materials | '''Specification'''<br> | ||
*Detection range: up to 3cm | * Sensing magnetic materials | ||
*Output: digital on/off | * Detection range: up to 3cm | ||
*Detection range and magnetic field strength are proportional | * Output: digital on/off | ||
* Detection range and magnetic field strength are proportional | |||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0020.png|700px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' | |||
<pre> | <pre> | ||
int ledPin = 13; // choose the pin for the LED | int ledPin = 13; // choose the pin for the LED | ||
int inputPin = 3; // Connect sensor to input pin 3 | int inputPin = 3; // Connect sensor to input pin 3 | ||
Line 685: | Line 773: | ||
void setup() { | void setup() { | ||
pinMode(ledPin, OUTPUT); // declare LED as output | pinMode(ledPin, OUTPUT); // declare LED as output | ||
pinMode(inputPin, INPUT); // declare | pinMode(inputPin, INPUT); // declare push button as input | ||
} | } | ||
Line 696: | Line 784: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Wire it up and upload well the code to board, you will see that D13 indicator on UNO board is off, and led on the module is also off. | |||
But if put a magnetic ball close to the hall module, you will see the D13 indicator on UNO board is turned on, and led on the module is also turned on. | |||
<br>[[File:KS0349 12-3.png|600px|frameless|thumb]]<br> | |||
<br> | |||
<br> | |||
=== '''Project 17: Line Tracking Sensor '''=== | === '''Project 17: Line Tracking Sensor '''=== | ||
'''Introduction | '''Introduction'''<br> | ||
This Line Tracking Sensor can detect white lines in black and black lines in white. The single line-tracking signal provides a stable output signal TTL for a more accurate and more stable line. Multi-channel option can be easily achieved by installing required line-tracking robot sensors. <br> | This Line Tracking Sensor can detect white lines in black and black lines in white. The single line-tracking signal provides a stable output signal TTL for a more accurate and more stable line. <br> | ||
Multi-channel option can be easily achieved by installing required line-tracking robot sensors. | |||
<br>[[File:KS0349 9-1.png|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
*Power supply: +5V | '''Specification'''<br> | ||
*Operating current: <10mA | * Power supply: +5V | ||
*Operating temperature range: 0°C ~ + 50°C | * Operating current: <10mA | ||
*Output interface: 3- | * Operating temperature range: 0°C ~ + 50°C | ||
*Output Level: TTL level | * Output interface: 3-PIN (1 - signal ; 2 - power ; 3 - power supply negative) | ||
* Output Level: TTL level | |||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0050-1.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
///Arduino Sample Code | ///Arduino Sample Code | ||
void setup() | void setup() | ||
Line 732: | Line 827: | ||
delay(500); | delay(500); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result '''<br> | |||
Done uploading the code to board, open the serial monitor and set the baud rate as 9600, then you can see the data from the sensor. Shown below. | |||
<br>[[File:KS0349 9-2.png|600px|frameless|thumb]]<br> | |||
=== '''Project 18: Infrared Obstacle Avoidance | |||
<br> | |||
=== '''Project 18: Infrared Obstacle Avoidance '''=== | |||
<br>[[File:KS0349 10-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 10-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
Infrared obstacle avoidance sensor is equipped with distance adjustment function and is especially designed for wheeled robots. This sensor has strong adaptability to ambient light and is of high precision. It has a pair of infrared transmitting and receiving tube. When infrared ray launched by the transmitting tube encounters an obstacle (its reflector), the infrared ray is reflected to the receiving tube, and the indicator will light up; the signal output interface outputs digital signal | Infrared obstacle avoidance sensor is equipped with distance adjustment function and is especially designed for wheeled robots. <br> | ||
This sensor has strong adaptability to ambient light and is of high precision. It has a pair of infrared transmitting and receiving tube. | |||
When infrared ray launched by the transmitting tube encounters an obstacle (its reflector), the infrared ray is reflected to the receiving tube, and the indicator will light up; the signal output interface outputs digital signal. <br> | |||
We can adjust the detection distance through the potentiometer knob (effective distance: 2~40cm, working Voltage: 3.3V-5V ). <br> | |||
Thanks to a wide voltage range, this sensor can work steadily even under fluctuating power supply voltage and is suitable for the use of various micro-controllers,Arduino controllers and BS2 controllers. | |||
A robot mounted with the sensor can sense changes in the environment.<br> | |||
''' | <br> | ||
'''Specification'''<br> | |||
* Working voltage: DC 3.3V-5V | |||
* Working current: ≥20mA | |||
* Working temperature: -10℃ to+50℃ | |||
* Detection distance: 2-40cm | |||
* IO Interface: 4 PIN (-/+/S/EN) | |||
* Output signal: TTL voltage | |||
* Accommodation mode: Multi-circle resistance regulation | |||
* Effective Angle: 35° | |||
''' | <br> | ||
'''Connection Diagram''' | |||
<br>[[File:0051.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
const int sensorPin = 3; // the number of the sensor pin | |||
const int sensorPin = | |||
const int ledPin = 13; // the number of the LED pin | const int ledPin = 13; // the number of the LED pin | ||
int sensorState = 0; // variable for reading the sensor status | int sensorState = 0; // variable for reading the sensor status | ||
Line 774: | Line 881: | ||
} | } | ||
else { | else { | ||
digitalWrite(ledPin, LOW); | digitalWrite(ledPin, LOW); | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Done uploading the code to board, you can see the led on both UNO board and obstacle detector sensor is turned on.<br> | |||
If we put a foam block in front of the sensor, this time when sensor detects the obstacle, sled on the sensor will be turned on. | |||
<br>[[File:KS0349 10-3.png|500px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 19: PIR Motion Sensor '''=== | === '''Project 19: PIR Motion Sensor '''=== | ||
Line 788: | Line 900: | ||
Pyroelectric infrared motion sensor can detect infrared signals from a moving person or moving animal, and output switching signals. It can be applied to a variety of occasions to detect the movement of human body. Conventional pyroelectric infrared sensors require body pyroelectric infrared detector, professional chip, complex peripheral circuit, so the size is bigger, with complex circuit, and lower reliability. Now we launch this new pyroelectric infrared motion sensor, specially designed for Arduino. It uses an integrated digital body pyroelectric infrared sensor, has smaller size, higher reliability, lower power consumption and simpler peripheral circuit. <br> | Pyroelectric infrared motion sensor can detect infrared signals from a moving person or moving animal, and output switching signals. It can be applied to a variety of occasions to detect the movement of human body. Conventional pyroelectric infrared sensors require body pyroelectric infrared detector, professional chip, complex peripheral circuit, so the size is bigger, with complex circuit, and lower reliability. Now we launch this new pyroelectric infrared motion sensor, specially designed for Arduino. It uses an integrated digital body pyroelectric infrared sensor, has smaller size, higher reliability, lower power consumption and simpler peripheral circuit. <br> | ||
<br> | |||
'''Specification:'''<br> | '''Specification:'''<br> | ||
*Input Voltage: 3.3 ~ 5V, 6V Maximum | *Input Voltage: 3.3 ~ 5V, 6V Maximum | ||
Line 798: | Line 911: | ||
*Output Indicator LED (When output HIGH, it will be ON) | *Output Indicator LED (When output HIGH, it will be ON) | ||
*Pin limit current: 100mA | *Pin limit current: 100mA | ||
<br> | |||
'''Connection Diagram:'''<br> | '''Connection Diagram:'''<br> | ||
<br>[[ | Connect the S pin of module to Digital 3 of UNO board, connect the negative pin to GND port, positive pin to 5V port. | ||
<br>[[Image:Ks0052.jpg|700px|frameless]]<br> | |||
<br> | |||
'''Sample Code:'''<br> | '''Sample Code:'''<br> | ||
<pre> | <pre> | ||
byte sensorPin = 3; | byte sensorPin = 3; | ||
byte indicator = 13; | byte indicator = 13; | ||
Line 826: | Line 938: | ||
delay(500); | delay(500); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Done wiring and powered up, upload well the code, if the sensor detects someone moving nearby, D13 indicator on UNO board will light up, and "Somebody is in this area!" is displayed on the serial monitor. <br> | |||
If no movement, D13 indicator on UNO board not lights, and "No one!" is displayed on the serial monitor. | |||
<br>[[Image:KS0335-4.jpg|800px|frameless]]<br> | |||
<br> | |||
=== '''Project 20: Flame Sensor '''=== | === '''Project 20: Flame Sensor '''=== | ||
<br>[[File:KS0349 16-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 16-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
This flame sensor can be used to detect fire or other lights | This flame sensor can be used to detect fire or other lights with wavelength stands at 760nm ~ 1100nm. <br> | ||
In the fire-fighting robot game, the flame plays an important role in the probe, which can be used as the robot's eyes to find fire source. | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
*Detection | *Detection Range: 20cm (4.8V) ~ 100cm (1V) | ||
*Rang of Spectral Bandwidth: 760nm to 1100nm | *Rang of Spectral Bandwidth: 760nm to 1100nm | ||
*Operating | *Operating Temperature: -25℃ to 85℃ | ||
*Interface: | *Interface: Digital | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' <br> | ||
Connect the D0 pin to digital 2, GND pin to GND port, VCC pin to 5V port. | |||
<br>[[File:Ks0036-1.png|700px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' | |||
<pre> | <pre> | ||
const int flamePin = 2; // the number of the flame pin | const int flamePin = 2; // the number of the flame pin | ||
const int ledPin = 13; // the number of the LED pin | const int ledPin = 13; // the number of the LED pin | ||
Line 865: | Line 984: | ||
State = digitalRead(flamePin); | State = digitalRead(flamePin); | ||
if (State == HIGH) { | if (State == HIGH) { | ||
// turn LED on: | // turn LED on: | ||
digitalWrite(ledPin, HIGH); | digitalWrite(ledPin, HIGH); | ||
Line 872: | Line 990: | ||
// turn LED off: | // turn LED off: | ||
digitalWrite(ledPin, LOW); | digitalWrite(ledPin, LOW); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Done wiring and powered up, upload well the code to the board. | |||
Then if you put a lighter close to the sensor, when the sensor detects the flame, another led on the sensor is turned on. | |||
<br>[[File:KS0349 16-3.png|800px|frameless|thumb]]<br> | |||
<br> | |||
<br> | |||
=== '''Project 21: Vibration Sensor '''=== | === '''Project 21: Vibration Sensor '''=== | ||
<br>[[File: | <br>[[File:KS0037 (2).jpg|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
What's the simplest way to check vibration with Arduino? Well, use a vibration sensor from keyestudio. You can directly plug it on our sensor Shield V5, vibrate this sensor, and Arduino can receive a digital signal, making it easy to make computation and programs in Arduino.<br> | What's the simplest way to check vibration with Arduino? Well, use a vibration sensor from keyestudio. You can directly plug it on our sensor Shield V5, vibrate this sensor, and Arduino can receive a digital signal, making it easy to make computation and programs in Arduino.<br> | ||
Despite its simplicity, you can make full use of it with creative thinking, step counting, and crash warning light etc. <br> | Despite its simplicity, you can make full use of it with creative thinking, step counting, and crash warning light etc. <br> | ||
<br> | |||
'''Specification:'''<br> | '''Specification:'''<br> | ||
*IO Type: Digital | *IO Type: Digital | ||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
<br> | |||
'''Connection Diagram:'''<br> | '''Connection Diagram:'''<br> | ||
<br>[[File: | <br>[[File:Ks0037.png|700px|frameless|thumb]]<br> | ||
<br> | |||
'''Sample Code:''' | |||
<pre> | <pre> | ||
#define SensorLED 13 | #define SensorLED 13 | ||
#define SensorINPUT 3 //Connect the sensor to digital Pin 3 which is Interrupts 1. | #define SensorINPUT 3 //Connect the sensor to digital Pin 3 which is Interrupts 1. | ||
Line 921: | Line 1,044: | ||
{ state++; | { state++; | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
=== '''Project 22: Analog Gas Sensor '''=== | === '''Project 22: Analog Gas Sensor '''=== | ||
<br>[[File:KS0349 25-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 25-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
This analog gas sensor - MQ2 is used in gas leakage detecting equipment in consumer electronics and industrial markets. This sensor is suitable for detecting LPG, I-butane, propane, methane, alcohol, Hydrogen and smoke. It has high sensitivity and quick response. In addition, the sensitivity can be adjusted by the potentiometer. <br> | This analog gas sensor - MQ2 is used in gas leakage detecting equipment in consumer electronics and industrial markets. This sensor is suitable for detecting LPG, I-butane, propane, methane, alcohol, Hydrogen and smoke. It has high sensitivity and quick response. In addition, the sensitivity can be adjusted by the potentiometer. <br> | ||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Power supply: 5V | *Power supply: 5V | ||
*Interface type: Analog | *Interface type: Analog | ||
Line 938: | Line 1,062: | ||
*Simple drive circuit | *Simple drive circuit | ||
*Stable and long lifespan | *Stable and long lifespan | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram'''<br> | ||
<br>[[File:Ks0040-1.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code'''<br> | |||
<pre> | <pre> | ||
///Arduino Sample Code | ///Arduino Sample Code | ||
void setup() | void setup() | ||
Line 960: | Line 1,082: | ||
delay(100); | delay(100); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Done wiring and powered up, upload well the code, then open the serial monitor and set the baud rate as 9600, you will see the analog value. <br> | |||
When detecting the gas, the value will make a change. | |||
<br>[[File:KS0349 25-3.png|600px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 23: Analog Alcohol Sensor '''=== | === '''Project 23: Analog Alcohol Sensor '''=== | ||
<br>[[File:KS0349 26-1.png|500px|frameless|thumb]]<br> | <br>[[File:KS0349 26-1.png|500px|frameless|thumb]]<br> | ||
'''Introduction | '''Introduction'''<br> | ||
This analog gas sensor - MQ3 is suitable for detecting alcohol. It can be used in a | This analog gas sensor - MQ3 is suitable for detecting alcohol. It can be used in a breath analyzer. <br> | ||
It has good selectivity because it has higher sensitivity to alcohol and lower sensitivity to Benzine. <br> | |||
The sensitivity can be adjusted by rotating the potentiometer.<br> | |||
'''Specification | <br> | ||
*Power | '''Specification'''<br> | ||
*Interface | *Power Supply: 5V | ||
*Interface Type: Analog | |||
*Quick response and High sensitivity | *Quick response and High sensitivity | ||
Simple drive circuit | *Simple drive circuit | ||
*Stable and long service life | *Stable and long service life | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0040-2.png|700px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' | |||
<pre> | <pre> | ||
///Arduino Sample Code | ///Arduino Sample Code | ||
void setup() | void setup() | ||
Line 997: | Line 1,127: | ||
delay(100); | delay(100); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' | |||
<br>[[File:KS0349 26-2.png|600px|frameless|thumb]]<br> | |||
Done wiring and powered up, upload well the code, then open the serial monitor and set the baud rate as 9600, you will see the analog value. <br> | |||
When detecting the alcohol gas, the value will make a change. | |||
<br>[[File:KS0349 26-3.png|600px|frameless|thumb]]<br> | |||
'''Introduction | <br> | ||
IR Transmitter Module is designed for IR communication which is widely used for operating the television device from a short line-of-sight distance. The remote control is usually contracted to remote.<br> | |||
Since infrared (IR) remote controls use light, they require line of sight to operate the destination device. The signal can, however, be reflected by mirrors, just like any other light | === '''Project 24: Digital IR Transmitter '''=== | ||
If operation is required where no line of sight is possible, for instance when controlling equipment in another room or installed in a cabinet, many brands of IR extenders are available for this on the market. Most of these have an IR receiver, picking up the IR signal and relaying it via radio waves to the remote part, which has an IR transmitter mimicking the original IR control.<br> | |||
Infrared receivers also tend to have a more or less limited operating angle, which mainly depends on the optical characteristics of the phototransistor. However, it’s easy to increase the operating angle using a matte transparent object in front of the receiver.<br> | '''Introduction'''<br> | ||
IR Transmitter Module is designed for IR communication which is widely used for operating the television device from a short line-of-sight distance. The remote control is usually contracted to remote. <br> | |||
Since infrared (IR) remote controls use light, they require line of sight to operate the destination device. The signal can, however, be reflected by mirrors, just like any other light sources. <br> | |||
If operation is required where no line of sight is possible, for instance when controlling equipment in another room or installed in a cabinet, many brands of IR extenders are available for this on the market. Most of these have an IR receiver, picking up the IR signal and relaying it via radio waves to the remote part, which has an IR transmitter mimicking the original IR control. <br> | |||
Infrared receivers also tend to have a more or less limited operating angle, which mainly depends on the optical characteristics of the phototransistor. However, it’s easy to increase the operating angle using a matte transparent object in front of the receiver. | |||
<br>[[File:KS0027 (5).jpg|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Power Supply: 3-5V | *Power Supply: 3-5V | ||
*Infrared | *Infrared Center Frequency: 850nm-940nm | ||
*Infrared | *Infrared Emission Angle: about 20degree | ||
*Infrared | *Infrared Emission Distance: about 1.3m (5V 38Khz) | ||
*Mounting Hole: inner diameter is 3.2mm, spacing is 15mm | |||
*Mounting | |||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0027.png|700px|frameless|thumb]]<br> | |||
'''Sample Code:''' | <br> | ||
'''Sample Code 1:''' | |||
<pre> | <pre> | ||
int led = 3; | int led = 3; | ||
void setup() { | void setup() { | ||
Line 1,032: | Line 1,169: | ||
void loop() { | void loop() { | ||
digitalWrite(led, HIGH); | digitalWrite(led, HIGH); | ||
delay(1000); | delay(1000); | ||
digitalWrite(led, LOW); | digitalWrite(led, LOW); | ||
delay(1000); } | delay(1000); | ||
} | |||
</pre> | |||
<br> | |||
< | |||
In the darkness of the environment, you are going to see blinking blue light on phone's screen when using camera to shoot the infrared LED.<br> | In the darkness of the environment, you are going to see blinking blue light on phone's screen when using camera to shoot the infrared LED.<br> | ||
Upload well the above code to the board, the led on the sensor will blink red light.<br> | |||
In the following, let’s move on to an interactive example between IR receiver and IR transmitter module. | |||
'''Infrared | |||
<br> | |||
'''Infrared Remote/Communication:'''<br> | |||
'''Hardware List'''<br> | |||
*UNO R3 x2 | *UNO R3 x2 | ||
*Digital IR Receiver x1 | *Digital IR Receiver x1 | ||
*IR Transmitter Module x1 | *IR Transmitter Module x1 | ||
Get Arduino library [https://github.com/z3t0/Arduino-IRremote Arduino-IRremote] and install it. <br> | |||
<br> | |||
< | <span style=color:red> Note: here if you have no two main boards, you can replace it with the breadboard for connection, may be more easier and convenient. <br> | ||
''' | <br> | ||
'''Connection Diagram'''<br> | |||
'''For IR Transmitter:''' <br> | |||
<span style=color:red> Notice: Arduino-IRremote only supports D3 as transmitter. <br> | |||
<br>[[File:Ks0027.png|700px|frameless|thumb]]<br> | |||
< | <br> | ||
Upload code to the UNO connected with IR Transmitter: | '''For IR Receiver:''' <br> | ||
connect it to D11 port. | |||
<br>[[File:Ks0027-2.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Upload code 2 to the UNO connected with IR Transmitter:'''<br> | |||
<pre> | |||
#include <IRremote.h> | #include <IRremote.h> | ||
IRsend irsend; | IRsend irsend; | ||
Line 1,070: | Line 1,218: | ||
delay(200); } | delay(200); } | ||
</pre> | </pre> | ||
Upload code to the UNO connected with IR Receiver: | |||
<br> | |||
'''Upload code 3 to the UNO connected with IR Receiver:'''<br> | |||
<pre> | <pre> | ||
#include <IRremote.h> | |||
const int RECV_PIN = 11; | const int RECV_PIN = 11; | ||
const int LED_PIN = 13; | const int LED_PIN = 13; | ||
Line 1,086: | Line 1,236: | ||
{ if ( results.bits > 0 ) | { if ( results.bits > 0 ) | ||
{ | { | ||
int state; | int state; | ||
if ( 0x1 == results.value ) | if ( 0x1 == results.value ) | ||
Line 1,100: | Line 1,249: | ||
irrecv.resume(); // prepare to receive the next value | irrecv.resume(); // prepare to receive the next value | ||
}} | }} | ||
</pre> | </pre> | ||
<br> | |||
<br>[[File: | '''Test Result''' <br> | ||
When IR Receiver module receives the infrared signal from IR Transmitter, D1 led on the IR Receiver module will blink.Shown as below figure. | |||
<br>[[File:KS0349 34-5.png|800px|frameless|thumb]]<br> | |||
'''Introduction | <br> | ||
IR is widely used in remote control. With this IR receiver, Arduino project is able to receive command from any IR remoter | |||
<br> | |||
=== '''Project 25: Digital IR Receiver '''=== | |||
'''Introduction'''<br> | |||
IR is widely used in remote control. With this IR receiver, Arduino project is able to receive command from any IR remoter controllers if you have right decoder. Well, it will be also easy to make your own IR controller using IR transmitter. | |||
<br>[[File:KS0026 (3).jpg|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Power Supply: 5V | *Power Supply: 5V | ||
*Interface:Digital | *Interface: Digital | ||
* | *Modulation Frequency: 38Khz | ||
<br> | |||
The following image shows a suggested connection method. You may use any Digital I/O pin that is not in use by another device. <br> | '''Connection Diagram''' <br> | ||
The following image shows a suggested connection method. You may use any Digital I/O pin that is not in use by another device. | |||
<br>[[File:Ks0026.png|700px|frameless|thumb]]<br> | |||
''' | <span style=color:red> '''NOTE:''' In the sample code below Digital pin 11 is in use, you may either change your wiring or change the sample code to match. <br> | ||
<br> | |||
<br> | |||
'''Sample Code''' <br> | |||
<span style=color:red> '''Note:''' before compiling the code, do remember to place the library into libraries directory of Arduino IDE. Otherwise, compiling will fail. <br> | |||
<pre> | <pre> | ||
#include <IRremote.h> | #include <IRremote.h> | ||
int RECV_PIN = 11; | int RECV_PIN = 11; | ||
Line 1,136: | Line 1,291: | ||
{ | { | ||
Serial.begin(9600); | Serial.begin(9600); | ||
irrecv.enableIRIn(); // Start the receiver | irrecv.enableIRIn(); // Start the receiver | ||
} | } | ||
Line 1,145: | Line 1,299: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
IR Remote Library | <br> | ||
https://github.com/shirriff/Arduino-IRremote | <span style=color:red> | ||
IR Remote Library includes some sample codes for sending and receiving: <br> | |||
[https://github.com/shirriff/Arduino-IRremote IR Remote Library] | |||
<br> | |||
'''Result''' <br> | |||
Done wiring and uploading the code, then control the IR receiver module by an infrared remote control, D1 led will flash. Shown as below. | |||
<br>[[File:KS0349 33-4.png|600px|frameless|thumb]]<br> | |||
=== '''Project 26: Rotary Encoder | <br> | ||
<br> | |||
=== '''Project 26: Rotary Encoder '''=== | |||
'''Introduction | '''Introduction'''<br> | ||
The rotary encoder can count the pulse outputting times during the process of | The rotary encoder can count the pulse outputting times during the process of rotation in positive and reverse direction by rotating. <br> | ||
This rotating counting is unlimited, not like potential counting. It can be restored to initial state to count from 0. | |||
<br>[[File:KS0013 (3).jpg|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Power Supply: 5V | *Power Supply: 5V | ||
*Interface: Digital | *Interface: Digital | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0013-1.png|700px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' | |||
<pre> | <pre> | ||
const int interruptA = 0; | const int interruptA = 0; | ||
const int interruptB = 1; | const int interruptB = 1; | ||
Line 1,187: | Line 1,350: | ||
pinMode(DAT, INPUT); | pinMode(DAT, INPUT); | ||
digitalWrite(3, HIGH); // Pull High Restance | digitalWrite(3, HIGH); // Pull High Restance | ||
pinMode(BUTTON, INPUT); | |||
digitalWrite(4, HIGH); // Pull High Restance | digitalWrite(4, HIGH); // Pull High Restance | ||
pinMode(LED1, OUTPUT); | pinMode(LED1, OUTPUT); | ||
Line 1,193: | Line 1,357: | ||
Serial.begin(9600); | Serial.begin(9600); | ||
} | } | ||
void loop() | void loop() | ||
Line 1,209: | Line 1,374: | ||
//------------------------------------------- | //------------------------------------------- | ||
void RoteStateChanged() //When CLK FALLING READ DAT | void RoteStateChanged() //When CLK FALLING READ DAT | ||
{ | { | ||
if (digitalRead(DAT)) // When DAT = HIGH IS FORWARD | if (digitalRead(DAT)) // When DAT = HIGH IS FORWARD | ||
Line 1,226: | Line 1,390: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result'''<br> | |||
Wiring well and uploading the above code, you can rotate the encoder module to randomly control two LED modules on and off. <br> | |||
When you rotate the encoder module, one LED module is turned on first but another one is off. If you continue to rotate the encoder module, one LED module becomes off while another one is turned on, repeatedly. | |||
<br>[[File:Ks0013.png|700px|frameless|thumb]]<br> | |||
=== '''Project 27: LM35 Linear Temperature | <br> | ||
<br> | |||
=== '''Project 27: LM35 Linear Temperature '''=== | |||
'''Introduction | '''Introduction'''<br> | ||
LM35 Linear Temperature Sensor is based on semiconductor LM35 temperature sensor. It can be used to detect ambient air temperature. This sensor offers a functional range among 0 degree Celsius to 100 degree Celsius. Sensitivity is 10mV per degree Celsius. The output voltage is proportional to the temperature.<br> | LM35 Linear Temperature Sensor is based on semiconductor LM35 temperature sensor. It can be used to detect ambient air temperature. <br> | ||
This sensor is commonly used as a temperature measurement sensor. It includes thermocouples, platinum resistance, and thermal resistance and temperature semiconductor chips. The chip is commonly used in high temperature measurement thermocouples. Platinum resistance temperature sensor is used in the measurement of 800 degrees Celsius, while the thermal resistance and semiconductor temperature sensor is suitable for measuring the temperature of 100-200 degrees or below, in which the application of a simple semiconductor temperature sensor is good in linearity and high in sensitivity. The LM35 linear temperature sensor and sensor-specific Arduino shield can be easily combined.<br> | This sensor offers a functional range among 0 degree Celsius to 100 degree Celsius. Sensitivity is 10mV per degree Celsius. The output voltage is proportional to the temperature.<br> | ||
This sensor is commonly used as a temperature measurement sensor. It includes thermocouples, platinum resistance, and thermal resistance and temperature semiconductor chips. <br> | |||
The chip is commonly used in high temperature measurement thermocouples. Platinum resistance temperature sensor is used in the measurement of 800 degrees Celsius, while the thermal resistance and semiconductor temperature sensor is suitable for measuring the temperature of 100-200 degrees or below, in which the application of a simple semiconductor temperature sensor is good in linearity and high in sensitivity. The LM35 linear temperature sensor and sensor-specific Arduino shield can be easily combined. | |||
<br>[[File:Ks0022-1.png|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Based on the semiconductor LM35 temperature sensor | *Based on the semiconductor LM35 temperature sensor | ||
*Can be used to detect ambient air temperature | *Can be used to detect ambient air temperature | ||
*Sensitivity: 10mV per degree Celcius | *Sensitivity: 10mV per degree Celcius | ||
*Functional | *Functional Range: 0 degree Celsius to 100 degree Celsius | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0022.png|700px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' | |||
<pre> | <pre> | ||
void setup() | void setup() | ||
{ | { | ||
Line 1,265: | Line 1,438: | ||
delay(500); | delay(500); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
<br>[[File:Ks0349-39-2.png|800px|frameless|thumb]]<br> | |||
Wire it up as the above diagram and upload well the code to the board, then open the serial monitor and set the baud rate as 9600, finally you will see the current temperature value shown below. The value may be slight difference due to different place and weather. | |||
<br>[[File:Ks0349-39-3.png|600px|frameless|thumb]]<br> | |||
=== '''Project 28: 18B20 Temperature Sensor '''=== | <br> | ||
<br>[[File: | |||
<br> | |||
=== '''Project 28: 18B20 Temperature Sensor '''=== | |||
<br>[[File:Ks0023.png|500px|frameless|thumb]]<br> | |||
'''Introduction:'''<br> | '''Introduction:'''<br> | ||
DS18B20 is a digital temperature sensor | DS18B20 is a digital temperature sensor. It can be used to quantify environmental temperature testing. <br> | ||
The temperature range is -55 ~ +125 ℃, inherent temperature resolution 0.5 ℃. It also support multi-point mesh networking. | The temperature range is -55 ~ +125 ℃, inherent temperature resolution 0.5 ℃. It also support multi-point mesh networking. <br> | ||
The DS18B20 can be deployed to achieve multi-point temperature measurement. It has a 9-12 bit serial output. | |||
<br> | |||
'''Specification:'''<br> | '''Specification:'''<br> | ||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
*Temperature range: -55 °C ~ +125 °C | *Temperature range: -55 °C ~ +125 °C | ||
*Interface: Digital | *Interface: Digital | ||
<br> | |||
'''Connection Diagram:'''<br> | '''Connection Diagram:'''<br> | ||
<br>[[File: | <br>[[File:Ks0023-.png|600px|frameless|thumb]]<br> | ||
<br> | |||
'''Sample Code:'''<br> | '''Sample Code:'''<br> | ||
OneWire Library Download: http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip | |||
<pre> | <pre> | ||
#include <OneWire.h> | #include <OneWire.h> | ||
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital pin 2 | |||
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 | |||
//Temperature chip i/o | //Temperature chip i/o | ||
OneWire ds(DS18S20_Pin); // on digital pin 2 | OneWire ds(DS18S20_Pin); // on digital pin 2 | ||
Line 1,303: | Line 1,483: | ||
Serial.println(temperature); | Serial.println(temperature); | ||
delay(100); // | delay(100); //to slow down the output so it is easier to read | ||
} | } | ||
float getTemp(){ | float getTemp(){ | ||
//returns the temperature from one DS18S20 in DEG Celsius | //returns the temperature from one DS18S20 in DEG Celsius | ||
Line 1,335: | Line 1,513: | ||
byte present = ds.reset(); | byte present = ds.reset(); | ||
ds.select(addr); | ds.select(addr); | ||
ds.write(0xBE); // Read Scratchpad | ds.write(0xBE); // Read Scratchpad | ||
Line 1,347: | Line 1,524: | ||
float tempRead = ((MSB << 8) | LSB); //using two's compliment | float tempRead = ((MSB << 8) | LSB); //using two's compliment | ||
float TemperatureSum = tempRead / 16; | float TemperatureSum = tempRead / 16; | ||
return TemperatureSum; | return TemperatureSum; | ||
} | } | ||
</pre> | </pre> | ||
Done uploading the code to the board, open the serial monitor, and you can see the measured temperature data. | |||
=== '''Project 29: ADXL345 Three Axis Acceleration | <br> | ||
=== '''Project 29: ADXL345 Three Axis Acceleration '''=== | |||
'''Introduction:'''<br> | '''Introduction:'''<br> | ||
The ADXL345 is a small, thin, low power, 3-axis MEMS accelerometer with high resolution (13-bit) measurement at up to +-16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.<br> | The ADXL345 is a small, thin, low power, 3-axis MEMS accelerometer with high resolution (13-bit) measurement at up to +-16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.<br> | ||
The ADXL345 is well suited to | The ADXL345 is well suited to measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0 degrees. | ||
<br>[[File:Ks0012-.png|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*2.0-3.6VDC Supply Voltage | *2.0-3.6VDC Supply Voltage | ||
*Ultra Low Power: 40uA in measurement mode, 0.1uA in standby@ 2.5V | *Ultra Low Power: 40uA in measurement mode, 0.1uA in standby@ 2.5V | ||
*Tap/Double Tap Detection | *Tap/Double Tap Detection | ||
*Free-Fall Detection | *Free-Fall Detection | ||
*SPI and I2C | *SPI and I2C Interface | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0012.png|700px|frameless|thumb]]<br> | |||
'''Sample Code | <br> | ||
'''Sample Code''' <br> | |||
The circuit connection is follows:<br> | |||
* VCC: 5V | |||
* GND: ground | |||
* SCL: UNO A5 | |||
* SDA: UNO A4 | |||
<pre> | <pre> | ||
#include <Wire.h> | #include <Wire.h> | ||
// Registers for ADXL345 | // Registers for ADXL345 | ||
Line 1,400: | Line 1,572: | ||
// writes data to the slave's buffer | // writes data to the slave's buffer | ||
void i2c_write(int address, byte reg, byte data) { | void i2c_write(int address, byte reg, byte data) { | ||
// Send output register address | // Send output register address | ||
Wire.beginTransmission(address); | Wire.beginTransmission(address); | ||
Line 1,424: | Line 1,597: | ||
// Request data from slave | // Request data from slave | ||
// Count stands for number of bytes to request | // Count stands for number of bytes to request | ||
Wire.requestFrom(address, count); | Wire.requestFrom(address, count); | ||
while(Wire.available()) // slave may send less than requested | while(Wire.available()) // slave may send less than requested | ||
Line 1,440: | Line 1,612: | ||
i2c_write(ADXL345_ADDRESS, 0x31, 0x0B); // 13-bit mode +_ 16g | i2c_write(ADXL345_ADDRESS, 0x31, 0x0B); // 13-bit mode +_ 16g | ||
i2c_write(ADXL345_ADDRESS, 0x2D, 0x08); // Power register | i2c_write(ADXL345_ADDRESS, 0x2D, 0x08); // Power register | ||
i2c_write(ADXL345_ADDRESS, 0x1E, 0x00); // x | i2c_write(ADXL345_ADDRESS, 0x1E, 0x00); // x | ||
Line 1,467: | Line 1,640: | ||
void setup() { | void setup() { | ||
Wire.begin(); | Wire.begin(); | ||
Serial.begin(9600); | Serial.begin(9600); | ||
for(int i=0; i<3; ++i) { | for(int i=0; i<3; ++i) { | ||
Line 1,474: | Line 1,646: | ||
init_adxl345(); | init_adxl345(); | ||
} | } | ||
void loop() { | void loop() { | ||
Line 1,481: | Line 1,654: | ||
Serial.print("\t"); | Serial.print("\t"); | ||
Serial.print(float(accelerometer_data[1])*3.9/1000); | Serial.print(float(accelerometer_data[1])*3.9/1000); | ||
Serial.print("\t"); | Serial.print("\t"); | ||
Serial.print(float(accelerometer_data[2])*3.9/1000); | Serial.print(float(accelerometer_data[2])*3.9/1000); | ||
Line 1,486: | Line 1,660: | ||
delay(100); | delay(100); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' | |||
<br>[[File:Ks0349-44-2.png|800px|frameless|thumb]]<br> | |||
Wiring as the above diagram and power on, then upload the code and open the serial monitor, it will display the triaxial acceleration of sensor and its status, as the graph shown below. | |||
<br>[[File:Ks0349-44-3.png|600px|frameless|thumb]]<br> | |||
<br> | |||
'''Introduction | === '''Project 30: DHT11 Temperature and Humidity Sensor '''=== | ||
This DHT11 Temperature and Humidity Sensor | |||
Each DHT11 sensor features extremely accurate calibration data of humidity calibration chamber. The calibration coefficients stored in the OTP program memory, internal sensors detect signals in the process, and we should call these calibration coefficients. The single-wire serial interface system is integrated to make it quick and easy. Qualities of small size, low power, and 20-meter signal transmission distance make it a wide applied application | '''Introduction'''<br> | ||
This DHT11 Temperature and Humidity Sensor is a composite sensor which contains a calibrated digital signal output of the temperature and humidity.<br> | |||
Its technology ensures high reliability and excellent long-term stability. A high-performance 8-bit microcontroller is connected. <br> | |||
This sensor includes a resistive element and a sense of wet NTC temperature measuring devices. It has excellent quality, fast response, anti-interference ability and high cost performance advantages.<br> | |||
Each DHT11 sensor features extremely accurate calibration data of humidity calibration chamber. The calibration coefficients stored in the OTP program memory, internal sensors detect signals in the process, and we should call these calibration coefficients. <br> | |||
The single-wire serial interface system is integrated to make it quick and easy. Qualities of small size, low power, and 20-meter signal transmission distance make it a wide applied application or even the most demanding one. Convenient connection, special packages can be provided according to users’ need. | |||
<br>[[File:KS0034 (3).jpg|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Supply Voltage: +5 V | *Supply Voltage: +5 V | ||
*Temperature | *Temperature Range: 0-50 °C error of ± 2 °C | ||
*Humidity: 20-90% RH ± 5% RH error | *Humidity: 20-90% RH ± 5% RH error | ||
*Interface: Digital | *Interface: Digital | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:0034.jpg|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' <br> | |||
Download the [https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib DHT11Lib].Or to see [http://playground.arduino.cc/Main/DHTLib the website] <br> | |||
''' | <span style=color:red> '''Note:''' before compiling the code, do remember to place the library into libraries directory of Arduino IDE. Otherwise, compiling will fail. </span><br> | ||
<pre> | <pre> | ||
#include <dht11.h> | #include <dht11.h> | ||
dht11 DHT; | dht11 DHT; | ||
Line 1,534: | Line 1,719: | ||
Serial.print("OK,\t"); | Serial.print("OK,\t"); | ||
break; | break; | ||
case DHTLIB_ERROR_CHECKSUM: | |||
Serial.print("Checksum error,\t"); | Serial.print("Checksum error,\t"); | ||
break; | break; | ||
Line 1,551: | Line 1,738: | ||
delay(1000); | delay(1000); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Wire it up well and upload the above code to UNO board. | |||
<br>[[File:Ks0349-40-2.png|800px|frameless|thumb]]<br> | |||
Then open the serial monitor and set the baud rate as 9600, finally you will see the current temperature and humidity value. | |||
<br>[[File:Ks0349-40-3.png|600px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 31: Bluetooth Module '''=== | === '''Project 31: Bluetooth Module '''=== | ||
<br>[[File: | <br>[[File:KS0055 (7).png|500px|frameless|thumb]]<br> | ||
'''Introduction | <br> | ||
This Bluetooth module can easily achieve serial wireless data transmission. Its operating frequency is among the most popular 2.4GHz ISM frequency band (i.e. Industrial, scientific and medical). It adopts Bluetooth 2.1+EDR standard. In Bluetooth 2.1, signal transmit time of different devices stands at a 0.5 seconds interval so that the workload of | '''Introduction'''<br> | ||
This Bluetooth module can easily achieve serial wireless data transmission. Its operating frequency is among the most popular 2.4GHz ISM frequency band (i.e. Industrial, scientific and medical). <br> | |||
It adopts Bluetooth 2.1+EDR standard. In Bluetooth 2.1, signal transmit time of different devices stands at a 0.5 seconds interval, so that the workload of Bluetooth chip can be reduced substantially and more sleeping time can be saved for Bluetooth. <br> | |||
This module is set with serial interface, which is easy-to-use and simplifying overall design/development cycle. | |||
'''Specification | <br> | ||
*Bluetooth protocol: Bluetooth 2.1+ EDR standard | '''Specification'''<br> | ||
*USB protocol: USB v1.1/2.0 | * Bluetooth protocol: Bluetooth 2.1+ EDR standard | ||
*Operating frequency: 2.4GHz ISM frequency band | * USB protocol: USB v1.1/2.0 | ||
*Modulation mode: Gauss frequency Shift Keying | * Operating frequency: 2.4GHz ISM frequency band | ||
*Transmit power: ≤ 4dBm, second stage | * Modulation mode: Gauss frequency Shift Keying | ||
*Sensitivity: ≤-84dBm at 0.1% Bit Error Rate | * Transmit power: ≤ 4dBm, second stage | ||
*Transmission speed: 2.1Mbps(Max)/160 kbps(Asynchronous); 1Mbps/1Mbps(Synchronous) | * Sensitivity: ≤-84dBm at 0.1% Bit Error Rate | ||
*Safety feature: Authentication and encryption | * Transmission speed: 2.1Mbps(Max)/160 kbps (Asynchronous); 1Mbps/1Mbps (Synchronous) | ||
*Supported configuration: Bluetooth serial port (major and minor) | * Safety feature: Authentication and encryption | ||
*Supply Voltage: | * Supported configuration: Bluetooth serial port (major and minor) | ||
*Operating temperature: -20 to 55℃ | * Supply Voltage: 5 V DC 50mA | ||
* Operating temperature: -20 to 55℃ | |||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:KS0055-1.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int val; | int val; | ||
int ledpin=13; | int ledpin=13; | ||
Line 1,600: | Line 1,797: | ||
} | } | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
=== '''Project 32: TEMT6000 Ambient Light '''=== | |||
<br>[[File:KS0098.jpg|450px|frameless|thumb]]<br> | |||
<br>[[File: | |||
'''Introduction:'''<br> | '''Introduction:'''<br> | ||
At some point you are going | At some point you are going to sense ambient brightness with better precision than your trusty photoresistor without adding complexity to your project. When that day comes, go get yourself a TEMT6000 ambient light sensor.<br> | ||
The TEMT6000 is supposed to be adapted to the sensitivity of the human eye, but | The TEMT6000 is supposed to be adapted to the sensitivity of the human eye, but found it preformed sub-par in low light conditions. <br> | ||
It does however work very well reacting to very small changes in a large range of brightness. Because it is meant to mimic the human eye, it does not react well to IR or UV light, so just make sure to note that when using it in your project.<br> | |||
<br> | |||
This is an incredibly simple part, just connect power and ground, and the signal pin to your favorite analog input and you are done, the sensor will output analog voltage, that ramps up when it gets brighter . You can power this off of 3.3v | '''Specification'''<br> | ||
* Supply Voltage: +5VDC 50mA | |||
* Size: 36.5*16mm | |||
* Weight: 4g | |||
<br> | |||
'''Connection Diagram''' <br> | |||
This is an incredibly simple part, just connect power and ground, and the signal pin to your favorite analog input and you are done, the sensor will output analog voltage, that ramps up when it gets brighter. <br> | |||
You can power this off of 3.3v as you like, the output value will just be lower.<br> | |||
<br>[[File:Ks0098.png|700px|frameless|thumb]]<br> | |||
Code<br> | <br> | ||
You can not get more | '''Sample Code'''<br> | ||
You can not get more simpler than this – This just reports the reading from the sensor to the serial terminal: 0-1023 with 1023 being very bright, and 0 being very dark.<br> | |||
<pre> | <pre> | ||
int temt6000Pin = 0; | int temt6000Pin = 0; | ||
void setup() { | void setup() { | ||
Serial.begin(9600); | |||
} | } | ||
void loop() { | void loop() { | ||
int value = analogRead(temt6000Pin); | |||
Serial.println(value); | |||
delay(100); //only here to slow down the output so it is easier to read | |||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
Wiring well and uploading the code above, open the serial monitor of Arduino software. | |||
<br>[[File:KS0349 31-3.png|800px|frameless|thumb]]<br> | |||
Then cover the sensor with your hand or a paper, the light becomes weak, finally you will see the value showed on monitor decrease. | |||
<br>[[File:KS0349 31-4.png|800px|frameless|thumb]]<br> | |||
<br> | |||
''' | === '''Project 33: SR01 Ultrasonic Sensor '''=== | ||
''' | '''Introduction'''<br> | ||
<br>[[File: | The Keyestudio SR01 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects. <br> | ||
It essentially gives your Arduino eyes/spacial awareness and can prevent your robot from crashing or falling off a table. It has also been used in turret applications, water level sensing, and even as a parking sensor. <br> | |||
This simple project will use the Keyestudio SR01 Ultrasonic Sensor with an Arduino and a Processing sketch to provide a neat little interactive display on your computer screen.<br> | |||
<br>[[File:2061.png|500px|frameless|thumb]]<br> | |||
''' | <br> | ||
'''Specification'''<br> | |||
* Working Voltage: DC 5V <br> | |||
* Working Current: 15mA <br> | |||
* Working Frequency: 40Hz <br> | |||
* Max Range: 5m <br> | |||
* Min Range: 2cm <br> | |||
* Measuring Angle: 15 degree <br> | |||
* Trigger Input Signal: 10µS TTL pulse <br> | |||
* Echo Output Signal Input TTL lever signal and the range in proportion <br> | |||
< | <br> | ||
**** | '''Connection Diagram''' | ||
#define echoPin 7 // Echo Pin | <br>[[File:2062.png|800px|frameless|thumb]]<br> | ||
<br> | |||
{| class="wikitable" border="1" | |||
|- | |||
! SR01 Ultrasonic Sensor | |||
! UNO | |||
|- | |||
| VCC | |||
| 5V | |||
|- | |||
| GND | |||
| GND | |||
|- | |||
| Echo | |||
|Digital Pin 7 | |||
|- | |||
| Trig | |||
|Digital Pin 8 | |||
|- | |||
|} | |||
<br> | |||
'''Sample Code'''<br> | |||
* VCC to arduino 5v <br> | |||
* GND to arduino GND<br> | |||
* Echo to Arduino pin 7 <br> | |||
* Trig to Arduino pin 8<br> | |||
<pre> | |||
#define echoPin 7 // Echo Pin | |||
#define trigPin 8 // Trigger Pin | #define trigPin 8 // Trigger Pin | ||
#define LEDPin 13 // Onboard LED | #define LEDPin 13 // Onboard LED | ||
Line 1,693: | Line 1,918: | ||
digitalWrite(trigPin, LOW); | digitalWrite(trigPin, LOW); | ||
delayMicroseconds(2); | delayMicroseconds(2); | ||
digitalWrite(trigPin, HIGH); | digitalWrite(trigPin, HIGH); | ||
delayMicroseconds(10); | delayMicroseconds(10); | ||
digitalWrite(trigPin, LOW); | digitalWrite(trigPin, LOW); | ||
duration = pulseIn(echoPin, HIGH); | duration = pulseIn(echoPin, HIGH); | ||
Line 1,717: | Line 1,944: | ||
delay(50); | delay(50); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' | |||
<br>[[File:Ks0206-1.png|600px|frameless|thumb]]<br> | |||
After upload the code to the board, open the serial monitor of Arduino IDE, you can see the distance value measured by ultrasonic sensor. | |||
<br>[[File:Ks0206-2.png|600px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 34: Joystick Module '''=== | === '''Project 34: Joystick Module '''=== | ||
'''Introduction | '''Introduction'''<br> | ||
Lots of robot projects need joystick. This module provides an affordable solution. By simply connecting to two analog inputs, the robot is at your commands with X, Y control. It also has a switch that is connected to a digital pin. This joystick module can be easily connected to Arduino by IO Shield. | Lots of robot projects need joystick. This module provides an affordable solution. By simply connecting to two analog inputs, the robot is at your commands with X, Y control. <br> | ||
It also has a switch that is connected to a digital pin. This joystick module can be easily connected to Arduino by IO Shield. | |||
<br>[[File:Ks0008_joystick.png|600px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Supply Voltage: 3.3V to 5V | *Supply Voltage: 3.3V to 5V | ||
*Interface: Analog x2, Digital x1 | *Interface: Analog x2, Digital x1 | ||
'''Connection Diagram | <br> | ||
<br>[[File: | '''Connection Diagram''' | ||
<br>[[File:Ks0008-1.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' | |||
<pre> | <pre> | ||
int JoyStick_X = 0; //x | int JoyStick_X = 0; //x | ||
int JoyStick_Y = 1; //y | int JoyStick_Y = 1; //y | ||
Line 1,752: | Line 1,985: | ||
int x,y,z; | int x,y,z; | ||
x=analogRead(JoyStick_X); | x=analogRead(JoyStick_X); | ||
y=analogRead(JoyStick_Y); | y=analogRead(JoyStick_Y); | ||
z=digitalRead(JoyStick_Z); | z=digitalRead(JoyStick_Z); | ||
Line 1,762: | Line 1,994: | ||
delay(100); | delay(100); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' | |||
<br>[[File:36.png|600px|frameless|thumb]]<br> | |||
Wiring well and uploading the code, open the serial monitor and set the baud rate to 9600, push the joystick, you will see the value shown below. | |||
<br>[[File:Joystick 1.jpg|600px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 35: DS3231 Clock Module '''=== | === '''Project 35: DS3231 Clock Module '''=== | ||
'''Introduction | '''Introduction'''<br> | ||
DS3231 is equipped with integrated TCXO and crystal, which | DS3231 is equipped with integrated TCXO and crystal, which make it a cost-effective I2C real time clock with high precision. <br> | ||
The device carries a battery input, so if you disconnect the main power supply, it can still maintain accurate timing.<br> | |||
The integrated oscillator ensures the long-term accuracy of the device and reduces the number of components. <br> | |||
DS3231 provides both commercial and industrial temperature range and supports 16 pins small-outline package (300mil). <br> | |||
The module itself can adapt to the system of 3.3V and 5V without level switch, which is quite convenient! <br> | |||
<br>[[File:Ks0039-1.png|400px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
*Temperature range: -40 to +85; Timing accuracy : ± 5ppm (±0.432 seconds / day) | '''Specification''' <br> | ||
*Temperature range: -40 to +85; Timing accuracy: ± 5ppm (±0.432 seconds/day) | |||
*Provide battery backup for continuous timing | *Provide battery backup for continuous timing | ||
*Low power consumption | *Low power consumption | ||
Line 1,786: | Line 2,029: | ||
*Working temperature: -40 ~ C to +85 ~ C | *Working temperature: -40 ~ C to +85 ~ C | ||
*16 pins Small Outline Package (300mil) | *16 pins Small Outline Package (300mil) | ||
'''Connection Diagram | <br> | ||
This module adopts the IIC test method, so we only need to connect | '''Connection Diagram''' <br> | ||
<br>[[File: | This module adopts the IIC test method, so we only need to connect SDA to Arduino A4; SCL to A5; positive pin to VCC; negative pin to GND. | ||
<br>[[File:Ks0039-2.png|700px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' <br> | |||
<span style=color:red> Before compiling the code, you’d better put [https://github.com/rodan/ds3231 DS3231 library] under file into Arduino catalogue. <br> | |||
<pre> | <pre> | ||
#include <Wire.h> | #include <Wire.h> | ||
#include "DS3231.h" | #include "DS3231.h" | ||
Line 1,804: | Line 2,047: | ||
//writing any non-existent time-data may interfere with normal operation of the RTC. | //writing any non-existent time-data may interfere with normal operation of the RTC. | ||
//Take care of week-day also. | //Take care of week-day also. | ||
DateTime dt(2011, 11, 10, 15, 18, 0, 5);//open the | DateTime dt(2011, 11, 10, 15, 18, 0, 5);//open the serial port and you can check time here or make a change to the time as needed. | ||
void setup () | void setup () | ||
{ Serial.begin(57600);//set baud rate to 57600 | { Serial.begin(57600);//set baud rate to 57600 | ||
Line 1,819: | Line 2,062: | ||
Serial.print('/'); | Serial.print('/'); | ||
Serial.print(now.date(), DEC); | Serial.print(now.date(), DEC); | ||
Serial.print(' '); | Serial.print(' '); | ||
Serial.print(now.hour(), DEC); | Serial.print(now.hour(), DEC); | ||
Line 1,830: | Line 2,074: | ||
delay(1000); | delay(1000); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
Before compiling the code, you’d better put | <span style=color:red> Before compiling the code, you’d better put [https://github.com/rodan/ds3231 DS3231 library] under file into Arduino catalogue. </span> <br> | ||
When the above steps are done, you can upload the code to arduino and open the serial monitor and get the following results: | |||
<br>[[File:ks0068 35-3.png|500px|frameless|thumb]]<br> | <br>[[File:ks0068 35-3.png|500px|frameless|thumb]]<br> | ||
<br> | |||
=== '''Project 36: 5V Relay Module '''=== | === '''Project 36: 5V Relay Module '''=== | ||
''' | '''Introducton'''<br> | ||
This single relay module can be used in interactive projects. This module uses SONGLE 5v high-quality relay. It can also be used to control lighting, electrical and other equipment. The modular design makes it easy to expand with the Arduino board (not included). The | This single relay module can be used in interactive projects. It is active HIGH level. This module uses SONGLE 5v high-quality relay. <br> | ||
It can also be used to control lighting, electrical and other equipment. <br> | |||
The modular design makes it easy to expand with the Arduino board (not included). The relay output is by a light-emitting diode. It can be controlled through digital IO port, such as solenoid valves, lamps, motors and other high current or high voltage devices. | |||
<br>[[File:Ks0011.png|500px|frameless|thumb]]<br> | |||
'''Specification | <br> | ||
'''Specification'''<br> | |||
*Type: Digital | *Type: Digital | ||
*Rated current: 10A (NO) 5A (NC) | *Rated current: 10A (NO) 5A (NC) | ||
Line 1,853: | Line 2,101: | ||
*Maximum switching power: AC1200VA DC240W (NO) AC625VA DC120W (NC) | *Maximum switching power: AC1200VA DC240W (NO) AC625VA DC120W (NC) | ||
*Contact action time: 10ms | *Contact action time: 10ms | ||
'''Connection Diagram | <br> | ||
'''Connection Diagram''' <br> | |||
Firstly you need to prepare the following parts by yourself before testing. <br> | |||
* Arduino Board*1 | |||
* Single relay module*1 | |||
* LED module *1 | |||
* USB Cable*1 | |||
* Jumper Wire*8 | |||
<br>[[File:Ks0011-1.png|500px|frameless|thumb]]<br> | |||
<br> | |||
'''Sample Code''' <br> | |||
Copy and paste the code below to Arduino software. | |||
<pre> | <pre> | ||
int Relay = 8; | |||
void setup() | void setup() | ||
{ | { | ||
pinMode(13, OUTPUT); //Set Pin13 as output | pinMode(13, OUTPUT); //Set Pin13 as output | ||
digitalWrite(13, HIGH); //Set Pin13 High | digitalWrite(13, HIGH); //Set Pin13 High | ||
Line 1,879: | Line 2,131: | ||
delay(2000); | delay(2000); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Test Result''' <br> | |||
This relay module is active HIGH level. <br> | |||
Wire it up well, powered up, then upload the above code to the board.<br> | |||
You will see the relay is turned on(ON connected, NC disconnected)for two seconds, then turned off for two seconds(NC closed,ON disconnected), repeatedly and circularly.<br> | |||
When the relay is turned on, external LED is on. If relay is turned off, external LED is off. | |||
<br>[[File:Ks0011-2.png|600px|frameless|thumb]]<br> | |||
<br> | |||
=== '''Project 37: Vapor Sensor '''=== | === '''Project 37: Vapor Sensor '''=== | ||
<br>[[File: | <br>[[File:2031.png|500px|frameless|thumb]]<br> | ||
'''Introduction:'''<br> | '''Introduction:'''<br> | ||
Steam sensor is an analog sensor and can be made as a simple rainwater detector and liquid level switch. When humidity on the face of this sensor rises, output voltage will increase. | |||
Caution: connection parts is non-waterproof, so please don’t put them into water. <br> | <span style=color:red> '''Caution:''' connection parts is non-waterproof, so please don’t put them into water. <br> | ||
''' | <br> | ||
*Working Voltage: 3.3V or 5V | '''Performance Parameters'''<br> | ||
*Working Current: <20mA | * 1.Working Voltage: 3.3V or 5V<br> | ||
*Range of Working Temperature: -10℃~+70℃ | * 2.Working Current: <20mA <br> | ||
*Interface Type: Analog Signal Output | * 3.Range of Working Temperature: -10℃~+70℃ <br> | ||
* 4.Interface Type: Analog Signal Output <br> | |||
<br> | |||
'''Pin Definition:''' <br> | |||
* '''S:'''Signal Output <br> | |||
* '''+:'''Power Supply(VCC) <br> | |||
* '''-:'''Ground(GND) <br> | |||
'''Connection Diagram | <br> | ||
'''Connection Diagram''' | |||
<br>[[File: | <br>[[File:2032.png|500px|frameless|thumb]]<br> | ||
<br> | |||
'''Test Code''' | |||
<pre> | <pre> | ||
void setup() | |||
{ | { | ||
Serial.begin(9600); //open serial port, and set baud rate at 9600bps | Serial.begin(9600); //open serial port, and set baud rate at 9600bps | ||
Line 1,923: | Line 2,182: | ||
delay(100); | delay(100); | ||
} | } | ||
</pre> | </pre> | ||
<br> | |||
'''Result''' <br> | |||
When detecting different degrees of humidity, the sensor will get the feedback of different current value. Shown as the following picture. <br> | |||
When the sensor detects the steam of boiled water, the moisture value is displayed on serial monitor of Arduino software. | |||
<br>[[File:203.jpg|600px|frameless|thumb]]<br> | |||
<br> | <br> | ||
==Resources == | ==Resources == | ||
* '''Video:''' <br> | * '''Video:''' <br> | ||
http://video.keyestudio.com/KS0068/ | http://video.keyestudio.com/KS0068/ | ||
* '''Libraries:''' <br> | * '''Libraries:''' <br> | ||
https:// | https://fs.keyestudio.com/KS0068 | ||
Latest revision as of 08:33, 7 January 2021
kesestudio 37 in 1 Sensor Kit for Arduino Starters
- Sensor kit for Arduino
- Based on open-source hardware
- 37 kinds of sensors packed in one box
- To make interesting projects
Summary
This is keyestudio sensor learning kit. We bring together 37 basic sensors and modules, aiming for the convenient learning for starters.
Inside this box, there are digital and analog sensors and also some special modules such as ultrasonic, Bluetooth, acceleration module,etc.
For each module, there is clear connection diagram and sample code. So even if you are totally new at this, you can get started easily.The sample codes for this sensor kit are based on ARDUINO because it's open source and easy to use.
If you are good at this, you can also apply this kit to other MCU development platforms, such as 51, STM32, Raspberries Pi.
The working principle is pretty much the same.
Now, let us embrace this fascinating world of ARDUINO and learn together!
Project Details
Project 1: White LED Light
Introduction
This is a white LED module. The main function is to control a plugin LED on and off. When connecting to ARDUINO, after programming, it will emit white light color.
The pin pitch of 3Pin is 2.54mm. This LED module has 3 Pins; - pin is connected to ground, + pin is connected to VCC(3.3-5V), S pin is for signal control; you can set the High or Low level to control the LED on and off.
You can combine with other sensors to do various interactive experiments.
You can also choose other LED modules to emit different light color like blue, green, yellow and red.
Features
- Control interface: Digital
- Working voltage: DC 3.3-5V
- Pin pitch: 2.54mm
- LED color: white
- Easy to use
- Useful for light projects
Connect It Up
Connect the LED module to control board using three jumper wires. Then connect the control board to your PC with a USB cable.
Upload the Code
Copy and paste below code to Arduino IDE and upload.
int led = 7; void setup() { pinMode(led, OUTPUT); //Set Pin7 as output } void loop() { digitalWrite(led, HIGH); //Turn off led delay(1000); digitalWrite(led, LOW); //Turn on led delay(1000); }
Test Result
The LED will flash on for one second, then off for one second, repeatedly and alternately.
If it doesn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board.
Project 2: Red LED Light
Introduction
This is a red LED module. The main function is to control a plugin LED on and off. When connecting to ARDUINO, after programming, it will emit red light color.
The pin pitch of 3Pin is 2.54mm.
This LED module has 3 Pins; - pin is connected to ground, + pin is connected to VCC(3.3-5V), S pin is for signal control; you can set the High or Low level to control the LED on and off.
You can combine with other sensors to do various interactive experiments.
You can also choose other LED modules to emit different light color like blue, green, yellow and white.
Features
- Control interface: Digital
- Working voltage: DC 3.3-5V
- Pin pitch: 2.54mm
- LED color: red
- Easy to use
- Useful for light projects
Technical Details
- Dimensions: 34mm*20mm*11.5mm
- Weight: 2.7g
Connect It Up
Connect the red LED module to control board using three jumper wires. Then connect the control board to your PC with a USB cable.
Upload the Code
Copy and paste below code to Arduino IDE and upload.
int led = 7; void setup() { pinMode(led, OUTPUT); //Set Pin7 as output } void loop() { digitalWrite(led, HIGH); //Turn off led delay(1000); digitalWrite(led, LOW); //Turn on led delay(1000); }
Test Result
The LED will flash on for one second, then off for one second, repeatedly and alternately.
If it doesn’t, make sure you have assembled the circuit correctly and verified and uploaded the code to your board.
Project 3: 3W LED Module
Introduction
This LED module is of high brightness because the lamp beads it carries is 3W. We can apply this module to Arduino projects.
For example, intelligent robots can use this module for illumination purpose.
Please note that the LED light can't be exposed directly to human eyes for safety concerns.
Specification
- Color temperature: 6000~7000K
- Luminous flux: 180~210lm
- Current: 700~750mA
- IO Type: Digital
- Supply Voltage: 3.3V to 5V
- Power: 3W
- Light angle: 140 degree
- Working temperature: -50~80℃
- Storage temperature: -50~100℃
- High power LED module, controlled by IO port microcontroller
- Great for Robot and search & rescue platform application
Sample Code
// the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
Result
Done wiring and powered up,upload well the code, both D13 led and the led on the module blink for one second then off, circularly.
Project 4: RGB LED
Introduction
This is a full-color LED module, which contains 3 basic colors-red, green and blue. They can be seen as separate LED lights.
After programming, you can turn them on and off by sequence or can also use PWM analog output to mix three colors to generate different colors.
Specification
- Color: red, green and blue
- Brightness: High
- Voltage: 5V
- Input: digital level
Sample Code
int redpin = 11; //select the pin for the red LED int bluepin =10; // select the pin for the blue LED int greenpin =9;// select the pin for the green LED int val; void setup() { pinMode(redpin, OUTPUT); pinMode(bluepin, OUTPUT); pinMode(greenpin, OUTPUT); } void loop() {for(val=255; val>0; val--) {analogWrite(11, val); analogWrite(10, 255-val); analogWrite(9, 128-val); delay(1); } for(val=0; val<255; val++) {analogWrite(11, val); analogWrite(10, 255-val); analogWrite(9, 128-val); delay(1); } }
Result
Done uploading the code, you should see the RGB LED flashing with different colors.
Project 5: Analog Temperature
Introduction
This module is based on the working principle of a thermistor (resistance varies with temperature change in the environment).
It can sense temperature change in its surrounding and send the data to the analog IO in the Arduino board.
All we need to do is to convert the sensor output data into degrees Celsius temperature via simple programming, finally to display it.
It's both convenient and effective, thus it is widely applied in gardening, home alarm system and other devices.
Specification
- Interface Type: analog
- Working Voltage: 5V
- Temperature Range: -55℃~315℃
Sample Code
Copy and paste the below code to Arduino software.
void setup() {Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() {int sensorValue = analogRead(A0); Serial.println(sensorValue); delay(1); }
The above code is only for analog value.
You can see that the analog value is changing according to the temperature change in the environment. But it’s not very obvious.
Let’s solve this by using the following equation. Then upload the code below to the Arduino board. The value read from the serial port is similar to normal temperature.
e.g. The temperature right now is 30°C.
#include <math.h> void setup() { Serial.begin(9600); } void loop() { double val=analogRead(0); double fenya=(val/1023)*5; double r=(5-fenya)/fenya*4700; Serial.println( 1/( log(r/10000) /3950 + 1/(25+273.15))-273.15); delay(1000); }
Result
Done wiring and powered up, upload well the code, then open the serial monitor, you will see the current temperature value. Shown below.
Project 6: Photocell Sensor
Introduction
Photocell is commonly seen in our daily life and is mainly used in intelligent switch, also in common electronic design.
To make it more easier and effective, we supply corresponding modules.
Photocell is a semiconductor. It has features of high sensitivity, quick response, spectral characteristic, and R-value consistence, maintaining high stability and reliability in environment extremes such as high temperature, high humidity.
It’s widely used in automatic control switch fields like cameras, garden solar lights, lawn lamps, money detectors, quartz clocks, music cups, gift boxes, mini night lights, sound and light control switches, etc.
Specification
- Interface Type: analog
- Working Voltage: 5V
Sample Code
int sensorPin =A0 ; int value = 0; void setup() { Serial.begin(9600); } void loop() { value = analogRead(sensorPin); Serial.println(value, DEC); delay(50); }
Result
Done wiring and powered up, upload well the code, then open the serial monitor, if cover the photocell on the sensor with your hand, you will see the analog value decrease. Shown as below.
Project 7: Analog Sound
Introduction
The keyestudio microphone sensor is typically used in detecting the loudness in ambient environment. The Arduino can collect its output signal by analog input interface.
The S pin is analog output, that is voltage signal real-time output of microphone. The sensor comes with a potentiometer, so that you can turn it to adjust the signal gain.
It also has a fixed hole so that you can mount the sensor on any other devices.
You can use it to make some interactive works, such as a voice operated switch.
Specification
- Operating voltage: 3.3V-5V(DC)
- Operating current: <10mA
- Interface:3PIN
- Output signal: Analog
Sample Code
int sensorPin =A0 ; // define analog port A0 int value = 0; //set value to 0 void setup() { Serial.begin(9600); //set the baud rate to 9600 } void loop() { value = analogRead(sensorPin); //set the value as the value read from A0 Serial.println(value, DEC); //print the value and line wrap delay(200); //delay 0.2S }
Test Result
Connect it up and upload the code successfully, then open the serial monitor on the right upper corner of Arduino IDE.
The analog value will pop up on the monitor window. The greater the sound, the greater the analog value is.
Project 8: Analog Rotation Sensor
Introduction
This analog Rotation Sensor is arduino compatible. It is based on a potentiometer. Its voltage can be subdivided into 1024, easy to be connected to Arduino with our sensor shield. Combined with other sensors, we can make interesting projects by reading the analog value from the IO port.
Specification
- Supply Voltage: 3.3V to 5V
- Interface: Analog
Sample Code
void setup() { Serial.begin(9600); //Set serial baud rate to 9600 bps } void loop() { int val; val=analogRead(0);//Read rotation sensor value from analog 0 Serial.println(val,DEC);//Print the value to serial port delay(100); }
Result
Done wiring and powered up, upload well the above code, then open the serial monitor and set the baud rate as 9600, finally you will see the analog value. If rotate the knob on the rotation sensor, the value will be changed within 0-1023. Shown below.
Project 9: Passive Buzzer
Introduction
We can use Arduino to make many interactive works of which the most commonly used is acoustic-optic display.
The circuit in this experiment can produce sound. Normally, the experiment is done with a buzzer or a speaker while buzzer is simpler and easier to use.
The buzzer we introduced here is a passive buzzer. It cannot be actuated by itself, but by external pulse frequencies. Different frequencies produce different sounds.
We can use Arduino to code the melody of a song, which is quite fun and simple.
Specification
- Working voltage: 3.3-5v
- Interface type: digital
Sample Code
int buzzer=3;//set digital IO pin of the buzzer void setup() { pinMode(buzzer,OUTPUT);// set digital IO pin pattern, OUTPUT to be output } void loop() { unsigned char i,j;//define variable while(1) { for(i=0;i<80;i++)// output a frequency sound { digitalWrite(buzzer,HIGH);// sound delay(1);//delay1ms digitalWrite(buzzer,LOW);//not sound delay(1);//ms delay } for(i=0;i<100;i++)// output a frequency sound { digitalWrite(buzzer,HIGH);// sound digitalWrite(buzzer,LOW);//not sound delay(2);//2ms delay } } }
Test Result
After downloading the program, buzzer experiment is complete. You should hear the buzzer ringing.
Project 10: Digital Buzzer
Introduction
Here is the simplest sound making module. You can use high/low level to drive it. Changing the frequency it buzzes can produce different sound. This module is widely used on your daily appliance, like PC, refrigerator, phones etc. And you can also create many interesting interactive project with this small but useful module.
Just try it!! You will find the electronic sound it creates so fascinating.
Specification
- Working Voltage: 3.3-5v
- Interface Type: digital
Sample Code
int buzzPin = 3; //Connect Buzzer on Digital Pin3 void setup() { pinMode(buzzPin, OUTPUT); } void loop() { digitalWrite(buzzPin, HIGH); delay(1); digitalWrite(buzzPin, LOW); delay(1); }
Test Result
After uploading the code, you can hear the buzzer beep continually.
Project 11: Digital Push Button
Introduction
This is a basic button application module. Momentary Pushbutton Switch usually stays open. When it is pressed down, circuit connected; when it is released, it will bounce back to the status of disconnection.
The module has three pins for easy connection. You can simply plug it into an IO shield to have your first try of Arduino.
Details
- Interface: Digital
- Supply Voltage: 3.3V to 5V
- Easy to plug and operate
- Large button keypad and high-quality button cap
- Standard assembling structure
- Easily recognizable pins
- Icons illustrate sensor function clearly
- Achieve interactive works
Sample Code
/* # When you push the digital button, the Led 13 on the board will turn on. Otherwise,the led turns off. */ int ledPin = 13; // choose the pin for the LED int inputPin = 3; // Connect sensor to input pin 3 void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare pushbutton as input } void loop(){ int val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, LOW); // turn LED OFF } else { digitalWrite(ledPin, HIGH); // turn LED ON } }
Result
When you push the digital button, the Led 13 on UNO board will be on. When release the button,the led is off. Shown as below.
Project 12: Digital Tilt Sensor
Introduction
Tilt sensor is a digital tilt switch. It can be used as a simple tilt sensor.
Tilt sensors (tilt ball switch) allow you to detect orientation or inclination. They are small, inexpensive, low-power and easy-to-use.
Simply connect the sensor to our IO/Sensor shield, so you can make amazing interactive projects.
Specification
- Supply Voltage: 3.3V to 5V
- Interface: Digital
Sample Code
int ledPin = 13; // Connect LED to pin 13 int switcher = 3; // Connect Tilt sensor to Pin3 void setup() { pinMode(ledPin, OUTPUT); // Set digital pin 13 to output mode pinMode(switcher, INPUT); // Set digital pin 3 to input mode } void loop() { if(digitalRead(switcher)==HIGH) //Read sensor value { digitalWrite(ledPin, HIGH); // Turn on LED when the sensor is tilted } else { digitalWrite(ledPin, LOW); // Turn off LED when the sensor is not triggered } }
Result
Upload the code to the board. Then tilt the sensor, you will see the led on the sensor is turned on. Shown as below.
Project 13: Photo Interrupter
Introduction
Upright part of this sensor is an infrared emitter and on the other side, it’s a shielded infrared detector. By emitting a beam of infrared light from one end to other end, the sensor can detect an object when it passes through the beam. It is used for many applications including optical limit switches, pellet dispensing, general object detection, etc.
Specification
- Supply Voltage: 3.3V to 5V
- Interface: Digital
Sample Code
// photo interrupter module int Led = 13 ;// define LED Interface int buttonpin = 3; // define the photo interrupter sensor interface int val ;// define numeric variables val void setup () { pinMode (Led, OUTPUT) ;// define LED as output interface pinMode (buttonpin, INPUT) ;// define the photo interrupter sensor output interface } void loop () { val = digitalRead (buttonpin) ;// digital interface will be assigned a value of 3 to read val if (val == HIGH) // When the light sensor detects a signal is interrupted, LED flashes { digitalWrite (Led, HIGH); } else { digitalWrite (Led, LOW); } }
Project 14: Capacitive Touch
Introduction
Are you tired of clicking mechanic button? Well, try our capacitive touch sensor. You can find touch sensors mostly used on electronic device. So upgrade your Arduino project with our new version touch sensor and make it cool!!
This little sensor can "feel" people and metal touch and feedback a high/low voltage level. Even isolated by some cloth and paper, it can still feel the touch. Its sensitivity decreases as isolation layer gets thicker.
Specification
- Supply Voltage: 3.3V to 5V
- Interface: Digital
Sample Code
int ledPin = 13; // Connect LED on pin 13, or use the onboard one int KEY = 2; // Connect Touch sensor on Digital Pin 2 void setup(){ pinMode(ledPin, OUTPUT); // Set ledPin to output mode pinMode(KEY, INPUT); //Set touch sensor pin to input mode } void loop(){ if(digitalRead(KEY)==HIGH) { //Read Touch sensor signal digitalWrite(ledPin, HIGH); // if Touch sensor is HIGH, then turn on } else{ digitalWrite(ledPin, LOW); // if Touch sensor is LOW, then turn off the led } }
Result
Done wiring and powered up, upload well the code, then touch the sensor with your finger, both D2 led on the sensor and D13 indicator on UNO board are on. Otherwise, those two indicators are turned off.
Project 15: Knock Module
This is a knock sensor module. When you knock it, it can send a momentary signal. You can combine it with Arduino to make some interesting experiment, e.g. electronic drum.
- Working voltage: 5V
Sample Code
int Led=13;//define LED interface int Shock=3;//define knock sensor interface int val;//define digital variable val void setup() { pinMode(Led,OUTPUT);//define LED to be output interface pinMode(Shock,INPUT);//define knock sensor to be output interface } void loop() { val=digitalRead(Shock);//read the value of interface3 and evaluate it to val if(val==HIGH)//when the knock sensor detect a signal, LED will be flashing { digitalWrite(Led,LOW); } else { digitalWrite(Led,HIGH); } }
Result
Upload the code to the board. When the sensor detects a knock signal, both the led on the sensor and led 13 on the UNO board are turned on.
Extension
You can extend to connect an external LED; when knock the sensor, the external LED will turn on. For example:
Project 16: Hall Magnetic Sensor
Introduction
This is a Magnetic Induction Sensor. It senses the magnetic materials within a detection range up to 3cm. The detection range and the strength of the magnetic field are proportional.The output is digital on/off.
This sensor uses the SFE Reed Switch - Magnetic Field Sensor.
Specification
- Sensing magnetic materials
- Detection range: up to 3cm
- Output: digital on/off
- Detection range and magnetic field strength are proportional
Sample Code
int ledPin = 13; // choose the pin for the LED int inputPin = 3; // Connect sensor to input pin 3 int val = 0; // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare push button as input } void loop(){ val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, LOW); // turn LED OFF } else { digitalWrite(ledPin, HIGH); // turn LED ON } }
Result
Wire it up and upload well the code to board, you will see that D13 indicator on UNO board is off, and led on the module is also off.
But if put a magnetic ball close to the hall module, you will see the D13 indicator on UNO board is turned on, and led on the module is also turned on.
Project 17: Line Tracking Sensor
Introduction
This Line Tracking Sensor can detect white lines in black and black lines in white. The single line-tracking signal provides a stable output signal TTL for a more accurate and more stable line.
Multi-channel option can be easily achieved by installing required line-tracking robot sensors.
Specification
- Power supply: +5V
- Operating current: <10mA
- Operating temperature range: 0°C ~ + 50°C
- Output interface: 3-PIN (1 - signal ; 2 - power ; 3 - power supply negative)
- Output Level: TTL level
Sample Code
///Arduino Sample Code void setup() { Serial.begin(9600); } void loop() { Serial.println(digitalRead(3)); // print the data from the sensor delay(500); }
Result
Done uploading the code to board, open the serial monitor and set the baud rate as 9600, then you can see the data from the sensor. Shown below.
Project 18: Infrared Obstacle Avoidance
Introduction
Infrared obstacle avoidance sensor is equipped with distance adjustment function and is especially designed for wheeled robots.
This sensor has strong adaptability to ambient light and is of high precision. It has a pair of infrared transmitting and receiving tube.
When infrared ray launched by the transmitting tube encounters an obstacle (its reflector), the infrared ray is reflected to the receiving tube, and the indicator will light up; the signal output interface outputs digital signal.
We can adjust the detection distance through the potentiometer knob (effective distance: 2~40cm, working Voltage: 3.3V-5V ).
Thanks to a wide voltage range, this sensor can work steadily even under fluctuating power supply voltage and is suitable for the use of various micro-controllers,Arduino controllers and BS2 controllers.
A robot mounted with the sensor can sense changes in the environment.
Specification
- Working voltage: DC 3.3V-5V
- Working current: ≥20mA
- Working temperature: -10℃ to+50℃
- Detection distance: 2-40cm
- IO Interface: 4 PIN (-/+/S/EN)
- Output signal: TTL voltage
- Accommodation mode: Multi-circle resistance regulation
- Effective Angle: 35°
Sample Code
const int sensorPin = 3; // the number of the sensor pin const int ledPin = 13; // the number of the LED pin int sensorState = 0; // variable for reading the sensor status void setup() { pinMode(ledPin, OUTPUT); pinMode(sensorPin, INPUT); } void loop(){ // read the state of the sensor value: sensorState = digitalRead(sensorPin); // if it is, the sensorState is HIGH: if (sensorState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } }
Result
Done uploading the code to board, you can see the led on both UNO board and obstacle detector sensor is turned on.
If we put a foam block in front of the sensor, this time when sensor detects the obstacle, sled on the sensor will be turned on.
Project 19: PIR Motion Sensor
Introduction:
Pyroelectric infrared motion sensor can detect infrared signals from a moving person or moving animal, and output switching signals. It can be applied to a variety of occasions to detect the movement of human body. Conventional pyroelectric infrared sensors require body pyroelectric infrared detector, professional chip, complex peripheral circuit, so the size is bigger, with complex circuit, and lower reliability. Now we launch this new pyroelectric infrared motion sensor, specially designed for Arduino. It uses an integrated digital body pyroelectric infrared sensor, has smaller size, higher reliability, lower power consumption and simpler peripheral circuit.
Specification:
- Input Voltage: 3.3 ~ 5V, 6V Maximum
- Working Current: 15uA
- Working Temperature: -20 ~ 85 ℃
- Output Voltage: High 3V, low 0V
- Output Delay Time (High Level): About 2.3 to 3 Seconds
- Detection angle: 100 °
- Detection distance: 7 meters
- Output Indicator LED (When output HIGH, it will be ON)
- Pin limit current: 100mA
Connection Diagram:
Connect the S pin of module to Digital 3 of UNO board, connect the negative pin to GND port, positive pin to 5V port.
Sample Code:
byte sensorPin = 3; byte indicator = 13; void setup() { pinMode(sensorPin,INPUT); pinMode(indicator,OUTPUT); Serial.begin(9600); } void loop() { byte state = digitalRead(sensorPin); digitalWrite(indicator,state); if(state == 1)Serial.println("Somebody is in this area!"); else if(state == 0)Serial.println("No one!"); delay(500); }
Result
Done wiring and powered up, upload well the code, if the sensor detects someone moving nearby, D13 indicator on UNO board will light up, and "Somebody is in this area!" is displayed on the serial monitor.
If no movement, D13 indicator on UNO board not lights, and "No one!" is displayed on the serial monitor.
Project 20: Flame Sensor
Introduction
This flame sensor can be used to detect fire or other lights with wavelength stands at 760nm ~ 1100nm.
In the fire-fighting robot game, the flame plays an important role in the probe, which can be used as the robot's eyes to find fire source.
Specification
- Supply Voltage: 3.3V to 5V
- Detection Range: 20cm (4.8V) ~ 100cm (1V)
- Rang of Spectral Bandwidth: 760nm to 1100nm
- Operating Temperature: -25℃ to 85℃
- Interface: Digital
Connection Diagram
Connect the D0 pin to digital 2, GND pin to GND port, VCC pin to 5V port.
Sample Code
const int flamePin = 2; // the number of the flame pin const int ledPin = 13; // the number of the LED pin // variables will change: int State = 0; // variable for reading status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(flamePin, INPUT); } void loop(){ // read the state of the value: State = digitalRead(flamePin); if (State == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); }
Result
Done wiring and powered up, upload well the code to the board.
Then if you put a lighter close to the sensor, when the sensor detects the flame, another led on the sensor is turned on.
Project 21: Vibration Sensor
Introduction
What's the simplest way to check vibration with Arduino? Well, use a vibration sensor from keyestudio. You can directly plug it on our sensor Shield V5, vibrate this sensor, and Arduino can receive a digital signal, making it easy to make computation and programs in Arduino.
Despite its simplicity, you can make full use of it with creative thinking, step counting, and crash warning light etc.
Specification:
- IO Type: Digital
- Supply Voltage: 3.3V to 5V
Sample Code:
#define SensorLED 13 #define SensorINPUT 3 //Connect the sensor to digital Pin 3 which is Interrupts 1. unsigned char state = 0; void setup() { pinMode(SensorLED, OUTPUT); pinMode(SensorINPUT, INPUT); attachInterrupt(1, blink, FALLING);// Trigger the blink function when the falling edge is detected } void loop() { if(state!=0) { state = 0; digitalWrite(SensorLED,HIGH); delay(500); } else digitalWrite(SensorLED,LOW); } void blink()//Interrupts function { state++; }
Project 22: Analog Gas Sensor
Introduction
This analog gas sensor - MQ2 is used in gas leakage detecting equipment in consumer electronics and industrial markets. This sensor is suitable for detecting LPG, I-butane, propane, methane, alcohol, Hydrogen and smoke. It has high sensitivity and quick response. In addition, the sensitivity can be adjusted by the potentiometer.
Specification
- Power supply: 5V
- Interface type: Analog
- Wide detecting scope
- Quick response and High sensitivity
- Simple drive circuit
- Stable and long lifespan
Sample Code
///Arduino Sample Code void setup() { Serial.begin(9600); //Set serial baud rate to 9600 bps } void loop() { int val; val=analogRead(0);//Read Gas value from analog 0 Serial.println(val,DEC);//Print the value to serial port delay(100); }
Result
Done wiring and powered up, upload well the code, then open the serial monitor and set the baud rate as 9600, you will see the analog value.
When detecting the gas, the value will make a change.
Project 23: Analog Alcohol Sensor
Introduction
This analog gas sensor - MQ3 is suitable for detecting alcohol. It can be used in a breath analyzer.
It has good selectivity because it has higher sensitivity to alcohol and lower sensitivity to Benzine.
The sensitivity can be adjusted by rotating the potentiometer.
Specification
- Power Supply: 5V
- Interface Type: Analog
- Quick response and High sensitivity
- Simple drive circuit
- Stable and long service life
Sample Code
///Arduino Sample Code void setup() { Serial.begin(9600); //Set serial baud rate to 9600 bps } void loop() { int val; val=analogRead(0);//Read Gas value from analog 0 Serial.println(val,DEC);//Print the value to serial port delay(100); }
Result
Done wiring and powered up, upload well the code, then open the serial monitor and set the baud rate as 9600, you will see the analog value.
When detecting the alcohol gas, the value will make a change.
Project 24: Digital IR Transmitter
Introduction
IR Transmitter Module is designed for IR communication which is widely used for operating the television device from a short line-of-sight distance. The remote control is usually contracted to remote.
Since infrared (IR) remote controls use light, they require line of sight to operate the destination device. The signal can, however, be reflected by mirrors, just like any other light sources.
If operation is required where no line of sight is possible, for instance when controlling equipment in another room or installed in a cabinet, many brands of IR extenders are available for this on the market. Most of these have an IR receiver, picking up the IR signal and relaying it via radio waves to the remote part, which has an IR transmitter mimicking the original IR control.
Infrared receivers also tend to have a more or less limited operating angle, which mainly depends on the optical characteristics of the phototransistor. However, it’s easy to increase the operating angle using a matte transparent object in front of the receiver.
Specification
- Power Supply: 3-5V
- Infrared Center Frequency: 850nm-940nm
- Infrared Emission Angle: about 20degree
- Infrared Emission Distance: about 1.3m (5V 38Khz)
- Mounting Hole: inner diameter is 3.2mm, spacing is 15mm
Sample Code 1:
int led = 3; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); delay(1000); }
In the darkness of the environment, you are going to see blinking blue light on phone's screen when using camera to shoot the infrared LED.
Upload well the above code to the board, the led on the sensor will blink red light.
In the following, let’s move on to an interactive example between IR receiver and IR transmitter module.
Infrared Remote/Communication:
Hardware List
- UNO R3 x2
- Digital IR Receiver x1
- IR Transmitter Module x1
Get Arduino library Arduino-IRremote and install it.
Note: here if you have no two main boards, you can replace it with the breadboard for connection, may be more easier and convenient.
Connection Diagram
For IR Transmitter:
Notice: Arduino-IRremote only supports D3 as transmitter.
For IR Receiver:
connect it to D11 port.
Upload code 2 to the UNO connected with IR Transmitter:
#include <IRremote.h> IRsend irsend; void setup() {} void loop() { irsend.sendRC5(0x0, 8); //send 0x0 code (8 bits) delay(200); irsend.sendRC5(0x1, 8); delay(200); }
Upload code 3 to the UNO connected with IR Receiver:
#include <IRremote.h> const int RECV_PIN = 11; const int LED_PIN = 13; IRrecv irrecv(RECV_PIN); decode_results results; void setup() {Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver } void loop() {if (irrecv.decode(&results)) { if ( results.bits > 0 ) { int state; if ( 0x1 == results.value ) { state = HIGH; } else { state = LOW; } digitalWrite( LED_PIN, state ); } irrecv.resume(); // prepare to receive the next value }}
Test Result
When IR Receiver module receives the infrared signal from IR Transmitter, D1 led on the IR Receiver module will blink.Shown as below figure.
Project 25: Digital IR Receiver
Introduction
IR is widely used in remote control. With this IR receiver, Arduino project is able to receive command from any IR remoter controllers if you have right decoder. Well, it will be also easy to make your own IR controller using IR transmitter.
Specification
- Power Supply: 5V
- Interface: Digital
- Modulation Frequency: 38Khz
Connection Diagram
The following image shows a suggested connection method. You may use any Digital I/O pin that is not in use by another device.
NOTE: In the sample code below Digital pin 11 is in use, you may either change your wiring or change the sample code to match.
Sample Code
Note: before compiling the code, do remember to place the library into libraries directory of Arduino IDE. Otherwise, compiling will fail.
#include <IRremote.h> int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value } }
IR Remote Library includes some sample codes for sending and receiving:
IR Remote Library
Result
Done wiring and uploading the code, then control the IR receiver module by an infrared remote control, D1 led will flash. Shown as below.
Project 26: Rotary Encoder
Introduction
The rotary encoder can count the pulse outputting times during the process of rotation in positive and reverse direction by rotating.
This rotating counting is unlimited, not like potential counting. It can be restored to initial state to count from 0.
Specification
- Power Supply: 5V
- Interface: Digital
Sample Code
const int interruptA = 0; const int interruptB = 1; int CLK = 2; // PIN2 int DAT = 3; // PIN3 int BUTTON = 4; // PIN4 int LED1 = 5; // PIN5 int LED2 = 6; // PIN6 int COUNT = 0; void setup() { attachInterrupt(interruptA, RoteStateChanged, FALLING); // attachInterrupt(interruptB, buttonState, FALLING); pinMode(CLK, INPUT); digitalWrite(2, HIGH); // Pull High Restance pinMode(DAT, INPUT); digitalWrite(3, HIGH); // Pull High Restance pinMode(BUTTON, INPUT); digitalWrite(4, HIGH); // Pull High Restance pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); Serial.begin(9600); } void loop() { if (!(digitalRead(BUTTON))) { COUNT = 0; Serial.println("STOP COUNT = 0"); digitalWrite(LED1, LOW); digitalWrite(LED2, LOW); delay (2000); } Serial.println(COUNT); } //------------------------------------------- void RoteStateChanged() //When CLK FALLING READ DAT { if (digitalRead(DAT)) // When DAT = HIGH IS FORWARD { COUNT++; digitalWrite(LED1, HIGH); digitalWrite(LED2, LOW); delay(20); } else // When DAT = LOW IS BackRote { COUNT--; digitalWrite(LED2, HIGH); digitalWrite(LED1, LOW); delay(20); } }
Result
Wiring well and uploading the above code, you can rotate the encoder module to randomly control two LED modules on and off.
When you rotate the encoder module, one LED module is turned on first but another one is off. If you continue to rotate the encoder module, one LED module becomes off while another one is turned on, repeatedly.
Project 27: LM35 Linear Temperature
Introduction
LM35 Linear Temperature Sensor is based on semiconductor LM35 temperature sensor. It can be used to detect ambient air temperature.
This sensor offers a functional range among 0 degree Celsius to 100 degree Celsius. Sensitivity is 10mV per degree Celsius. The output voltage is proportional to the temperature.
This sensor is commonly used as a temperature measurement sensor. It includes thermocouples, platinum resistance, and thermal resistance and temperature semiconductor chips.
The chip is commonly used in high temperature measurement thermocouples. Platinum resistance temperature sensor is used in the measurement of 800 degrees Celsius, while the thermal resistance and semiconductor temperature sensor is suitable for measuring the temperature of 100-200 degrees or below, in which the application of a simple semiconductor temperature sensor is good in linearity and high in sensitivity. The LM35 linear temperature sensor and sensor-specific Arduino shield can be easily combined.
Specification
- Based on the semiconductor LM35 temperature sensor
- Can be used to detect ambient air temperature
- Sensitivity: 10mV per degree Celcius
- Functional Range: 0 degree Celsius to 100 degree Celsius
Sample Code
void setup() { Serial.begin(9600);//Set Baud Rate to 9600 bps } void loop() { int val; int dat; val=analogRead(0);//Connect LM35 on Analog 0 dat=(500 * val) /1024;; Serial.print("Temp:"); //Display the temperature on Serial monitor Serial.print(dat); Serial.println("C"); delay(500); }
Result
Wire it up as the above diagram and upload well the code to the board, then open the serial monitor and set the baud rate as 9600, finally you will see the current temperature value shown below. The value may be slight difference due to different place and weather.
Project 28: 18B20 Temperature Sensor
Introduction:
DS18B20 is a digital temperature sensor. It can be used to quantify environmental temperature testing.
The temperature range is -55 ~ +125 ℃, inherent temperature resolution 0.5 ℃. It also support multi-point mesh networking.
The DS18B20 can be deployed to achieve multi-point temperature measurement. It has a 9-12 bit serial output.
Specification:
- Supply Voltage: 3.3V to 5V
- Temperature range: -55 °C ~ +125 °C
- Interface: Digital
Sample Code:
OneWire Library Download: http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip
#include <OneWire.h> int DS18S20_Pin = 2; //DS18S20 Signal pin on digital pin 2 //Temperature chip i/o OneWire ds(DS18S20_Pin); // on digital pin 2 void setup(void) { Serial.begin(9600); } void loop(void) { float temperature = getTemp(); Serial.println(temperature); delay(100); //to slow down the output so it is easier to read } float getTemp(){ //returns the temperature from one DS18S20 in DEG Celsius byte data[12]; byte addr[8]; if ( !ds.search(addr)) { //no more sensors on chain, reset search ds.reset_search(); return -1000; } if ( OneWire::crc8( addr, 7) != addr[7]) { Serial.println("CRC is not valid!"); return -1000; } if ( addr[0] != 0x10 && addr[0] != 0x28) { Serial.print("Device is not recognized"); return -1000; } ds.reset(); ds.select(addr); ds.write(0x44,1); // start conversion, with parasite power on at the end byte present = ds.reset(); ds.select(addr); ds.write(0xBE); // Read Scratchpad for (int i = 0; i < 9; i++) { // we need 9 bytes data[i] = ds.read(); } ds.reset_search(); byte MSB = data[1]; byte LSB = data[0]; float tempRead = ((MSB << 8) | LSB); //using two's compliment float TemperatureSum = tempRead / 16; return TemperatureSum; }
Done uploading the code to the board, open the serial monitor, and you can see the measured temperature data.
Project 29: ADXL345 Three Axis Acceleration
Introduction:
The ADXL345 is a small, thin, low power, 3-axis MEMS accelerometer with high resolution (13-bit) measurement at up to +-16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.
The ADXL345 is well suited to measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0 degrees.
Specification
- 2.0-3.6VDC Supply Voltage
- Ultra Low Power: 40uA in measurement mode, 0.1uA in standby@ 2.5V
- Tap/Double Tap Detection
- Free-Fall Detection
- SPI and I2C Interface
Sample Code
The circuit connection is follows:
- VCC: 5V
- GND: ground
- SCL: UNO A5
- SDA: UNO A4
#include <Wire.h> // Registers for ADXL345 #define ADXL345_ADDRESS (0xA6 >> 1) // address for device is 8 bit but shift to the // right by 1 bit to make it 7 bit because the // wire library only takes in 7 bit addresses #define ADXL345_REGISTER_XLSB (0x32) int accelerometer_data[3]; // void because this only tells the cip to send data to its output register // writes data to the slave's buffer void i2c_write(int address, byte reg, byte data) { // Send output register address Wire.beginTransmission(address); // Connect to device Wire.write(reg); // Send data Wire.write(data); //low byte Wire.endTransmission(); } // void because using pointers // microcontroller reads data from the sensor's input register void i2c_read(int address, byte reg, int count, byte* data) { // Used to read the number of data received int i = 0; // Send input register address Wire.beginTransmission(address); // Connect to device Wire.write(reg); Wire.endTransmission(); // Connect to device Wire.beginTransmission(address); // Request data from slave // Count stands for number of bytes to request Wire.requestFrom(address, count); while(Wire.available()) // slave may send less than requested { char c = Wire.read(); // receive a byte as character data[i] = c; i++; } Wire.endTransmission(); } void init_adxl345() { byte data = 0; i2c_write(ADXL345_ADDRESS, 0x31, 0x0B); // 13-bit mode +_ 16g i2c_write(ADXL345_ADDRESS, 0x2D, 0x08); // Power register i2c_write(ADXL345_ADDRESS, 0x1E, 0x00); // x i2c_write(ADXL345_ADDRESS, 0x1F, 0x00); // Y i2c_write(ADXL345_ADDRESS, 0x20, 0x05); // Z // Check to see if it worked! i2c_read(ADXL345_ADDRESS, 0X00, 1, &data); if(data==0xE5) Serial.println("it work Success"); else Serial.println("it work Fail"); } void read_adxl345() { byte bytes[6]; memset(bytes,0,6); // Read 6 bytes from the ADXL345 i2c_read(ADXL345_ADDRESS, ADXL345_REGISTER_XLSB, 6, bytes); // Unpack data for (int i=0;i<3;++i) { accelerometer_data[i] = (int)bytes[2*i] + (((int)bytes[2*i + 1]) << 8); } } // initialise and start everything void setup() { Wire.begin(); Serial.begin(9600); for(int i=0; i<3; ++i) { accelerometer_data[i] = 0; } init_adxl345(); } void loop() { read_adxl345(); Serial.print("ACCEL: "); Serial.print(float(accelerometer_data[0])*3.9/1000);//3.9mg/LSB scale factor in 13-bit mode Serial.print("\t"); Serial.print(float(accelerometer_data[1])*3.9/1000); Serial.print("\t"); Serial.print(float(accelerometer_data[2])*3.9/1000); Serial.print("\n"); delay(100); }
Result
Wiring as the above diagram and power on, then upload the code and open the serial monitor, it will display the triaxial acceleration of sensor and its status, as the graph shown below.
Project 30: DHT11 Temperature and Humidity Sensor
Introduction
This DHT11 Temperature and Humidity Sensor is a composite sensor which contains a calibrated digital signal output of the temperature and humidity.
Its technology ensures high reliability and excellent long-term stability. A high-performance 8-bit microcontroller is connected.
This sensor includes a resistive element and a sense of wet NTC temperature measuring devices. It has excellent quality, fast response, anti-interference ability and high cost performance advantages.
Each DHT11 sensor features extremely accurate calibration data of humidity calibration chamber. The calibration coefficients stored in the OTP program memory, internal sensors detect signals in the process, and we should call these calibration coefficients.
The single-wire serial interface system is integrated to make it quick and easy. Qualities of small size, low power, and 20-meter signal transmission distance make it a wide applied application or even the most demanding one. Convenient connection, special packages can be provided according to users’ need.
Specification
- Supply Voltage: +5 V
- Temperature Range: 0-50 °C error of ± 2 °C
- Humidity: 20-90% RH ± 5% RH error
- Interface: Digital
Sample Code
Download the DHT11Lib.Or to see the website
Note: before compiling the code, do remember to place the library into libraries directory of Arduino IDE. Otherwise, compiling will fail.
#include <dht11.h> dht11 DHT; #define DHT11_PIN 4 void setup(){ Serial.begin(9600); Serial.println("DHT TEST PROGRAM "); Serial.print("LIBRARY VERSION: "); Serial.println(DHT11LIB_VERSION); Serial.println(); Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)"); } void loop(){ int chk; Serial.print("DHT11, \t"); chk = DHT.read(DHT11_PIN); // READ DATA switch (chk){ case DHTLIB_OK: Serial.print("OK,\t"); break; case DHTLIB_ERROR_CHECKSUM: Serial.print("Checksum error,\t"); break; case DHTLIB_ERROR_TIMEOUT: Serial.print("Time out error,\t"); break; default: Serial.print("Unknown error,\t"); break; } // DISPLAT DATA Serial.print(DHT.humidity,1); Serial.print(",\t"); Serial.println(DHT.temperature,1); delay(1000); }
Result
Wire it up well and upload the above code to UNO board.
Then open the serial monitor and set the baud rate as 9600, finally you will see the current temperature and humidity value.
Project 31: Bluetooth Module
Introduction
This Bluetooth module can easily achieve serial wireless data transmission. Its operating frequency is among the most popular 2.4GHz ISM frequency band (i.e. Industrial, scientific and medical).
It adopts Bluetooth 2.1+EDR standard. In Bluetooth 2.1, signal transmit time of different devices stands at a 0.5 seconds interval, so that the workload of Bluetooth chip can be reduced substantially and more sleeping time can be saved for Bluetooth.
This module is set with serial interface, which is easy-to-use and simplifying overall design/development cycle.
Specification
- Bluetooth protocol: Bluetooth 2.1+ EDR standard
- USB protocol: USB v1.1/2.0
- Operating frequency: 2.4GHz ISM frequency band
- Modulation mode: Gauss frequency Shift Keying
- Transmit power: ≤ 4dBm, second stage
- Sensitivity: ≤-84dBm at 0.1% Bit Error Rate
- Transmission speed: 2.1Mbps(Max)/160 kbps (Asynchronous); 1Mbps/1Mbps (Synchronous)
- Safety feature: Authentication and encryption
- Supported configuration: Bluetooth serial port (major and minor)
- Supply Voltage: 5 V DC 50mA
- Operating temperature: -20 to 55℃
Sample Code
int val; int ledpin=13; void setup() { Serial.begin(9600); pinMode(ledpin,OUTPUT); } void loop() { val=Serial.read(); if(val=='a') { digitalWrite(ledpin,HIGH); delay(250); digitalWrite(ledpin,LOW); delay(250); Serial.println("keyestudio"); } }
Project 32: TEMT6000 Ambient Light
Introduction:
At some point you are going to sense ambient brightness with better precision than your trusty photoresistor without adding complexity to your project. When that day comes, go get yourself a TEMT6000 ambient light sensor.
The TEMT6000 is supposed to be adapted to the sensitivity of the human eye, but found it preformed sub-par in low light conditions.
It does however work very well reacting to very small changes in a large range of brightness. Because it is meant to mimic the human eye, it does not react well to IR or UV light, so just make sure to note that when using it in your project.
Specification
- Supply Voltage: +5VDC 50mA
- Size: 36.5*16mm
- Weight: 4g
Connection Diagram
This is an incredibly simple part, just connect power and ground, and the signal pin to your favorite analog input and you are done, the sensor will output analog voltage, that ramps up when it gets brighter.
You can power this off of 3.3v as you like, the output value will just be lower.
Sample Code
You can not get more simpler than this – This just reports the reading from the sensor to the serial terminal: 0-1023 with 1023 being very bright, and 0 being very dark.
int temt6000Pin = 0; void setup() { Serial.begin(9600); } void loop() { int value = analogRead(temt6000Pin); Serial.println(value); delay(100); //only here to slow down the output so it is easier to read }
Result
Wiring well and uploading the code above, open the serial monitor of Arduino software.
Then cover the sensor with your hand or a paper, the light becomes weak, finally you will see the value showed on monitor decrease.
Project 33: SR01 Ultrasonic Sensor
Introduction
The Keyestudio SR01 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects.
It essentially gives your Arduino eyes/spacial awareness and can prevent your robot from crashing or falling off a table. It has also been used in turret applications, water level sensing, and even as a parking sensor.
This simple project will use the Keyestudio SR01 Ultrasonic Sensor with an Arduino and a Processing sketch to provide a neat little interactive display on your computer screen.
Specification
- Working Voltage: DC 5V
- Working Current: 15mA
- Working Frequency: 40Hz
- Max Range: 5m
- Min Range: 2cm
- Measuring Angle: 15 degree
- Trigger Input Signal: 10µS TTL pulse
- Echo Output Signal Input TTL lever signal and the range in proportion
SR01 Ultrasonic Sensor | UNO |
---|---|
VCC | 5V |
GND | GND |
Echo | Digital Pin 7 |
Trig | Digital Pin 8 |
Sample Code
- VCC to arduino 5v
- GND to arduino GND
- Echo to Arduino pin 7
- Trig to Arduino pin 8
#define echoPin 7 // Echo Pin #define trigPin 8 // Trigger Pin #define LEDPin 13 // Onboard LED int maximumRange = 200; // Maximum range needed int minimumRange = 0; // Minimum range needed long duration, distance; // Duration used to calculate distance void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(LEDPin, OUTPUT); // Use LED indicator (if required) } void loop() { /* The following trigPin/echoPin cycle is used to determine the distance of the nearest object by bouncing soundwaves off of it. */ digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); //Calculate the distance (in cm) based on the speed of sound. distance = duration/58.2; if (distance >= maximumRange || distance <= minimumRange){ /* Send a negative number to computer and Turn LED ON to indicate "out of range" */ Serial.println("-1"); digitalWrite(LEDPin, HIGH); } else { /* Send the distance to the computer using Serial protocol, and turn LED OFF to indicate successful reading. */ Serial.println(distance); digitalWrite(LEDPin, LOW); } //Delay 50ms before next reading. delay(50); }
Result
After upload the code to the board, open the serial monitor of Arduino IDE, you can see the distance value measured by ultrasonic sensor.
Project 34: Joystick Module
Introduction
Lots of robot projects need joystick. This module provides an affordable solution. By simply connecting to two analog inputs, the robot is at your commands with X, Y control.
It also has a switch that is connected to a digital pin. This joystick module can be easily connected to Arduino by IO Shield.
Specification
- Supply Voltage: 3.3V to 5V
- Interface: Analog x2, Digital x1
Sample Code
int JoyStick_X = 0; //x int JoyStick_Y = 1; //y int JoyStick_Z = 3; //key void setup() { pinMode(JoyStick_Z, INPUT); Serial.begin(9600); // 9600 bps } void loop() { int x,y,z; x=analogRead(JoyStick_X); y=analogRead(JoyStick_Y); z=digitalRead(JoyStick_Z); Serial.print(x ,DEC); Serial.print(","); Serial.print(y ,DEC); Serial.print(","); Serial.println(z ,DEC); delay(100); }
Result
Wiring well and uploading the code, open the serial monitor and set the baud rate to 9600, push the joystick, you will see the value shown below.
Project 35: DS3231 Clock Module
Introduction
DS3231 is equipped with integrated TCXO and crystal, which make it a cost-effective I2C real time clock with high precision.
The device carries a battery input, so if you disconnect the main power supply, it can still maintain accurate timing.
The integrated oscillator ensures the long-term accuracy of the device and reduces the number of components.
DS3231 provides both commercial and industrial temperature range and supports 16 pins small-outline package (300mil).
The module itself can adapt to the system of 3.3V and 5V without level switch, which is quite convenient!
Specification
- Temperature range: -40 to +85; Timing accuracy: ± 5ppm (±0.432 seconds/day)
- Provide battery backup for continuous timing
- Low power consumption
- Device package and function compatible with DS3231
- Complete clock calendar function contains seconds and minutes, hour, week, date, month, and year timing and provides leap year compensation until 2100.
- Two calendar clock
- Output: 1Hz and 32.768kHz
- Reset output and Input Debounce of Pushbutton
- High speed (400kHz), I2C serial bus
- Supply voltage: +3.3V to +5.5V
- Digital temperature sensor with a precision of±3℃
- Working temperature: -40 ~ C to +85 ~ C
- 16 pins Small Outline Package (300mil)
Connection Diagram
This module adopts the IIC test method, so we only need to connect SDA to Arduino A4; SCL to A5; positive pin to VCC; negative pin to GND.
Sample Code
Before compiling the code, you’d better put DS3231 library under file into Arduino catalogue.
#include <Wire.h> #include "DS3231.h" DS3231 RTC; //Create the DS3231 object char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; //year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6) //writing any non-existent time-data may interfere with normal operation of the RTC. //Take care of week-day also. DateTime dt(2011, 11, 10, 15, 18, 0, 5);//open the serial port and you can check time here or make a change to the time as needed. void setup () { Serial.begin(57600);//set baud rate to 57600 Wire.begin(); RTC.begin(); RTC.adjust(dt); //Adjust date-time as defined 'dt' above } void loop () { DateTime now = RTC.now(); //get the current date-time Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.date(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); Serial.print(weekDay[now.dayOfWeek()]); Serial.println(); delay(1000); }
Before compiling the code, you’d better put DS3231 library under file into Arduino catalogue.
When the above steps are done, you can upload the code to arduino and open the serial monitor and get the following results:
Project 36: 5V Relay Module
Introducton
This single relay module can be used in interactive projects. It is active HIGH level. This module uses SONGLE 5v high-quality relay.
It can also be used to control lighting, electrical and other equipment.
The modular design makes it easy to expand with the Arduino board (not included). The relay output is by a light-emitting diode. It can be controlled through digital IO port, such as solenoid valves, lamps, motors and other high current or high voltage devices.
Specification
- Type: Digital
- Rated current: 10A (NO) 5A (NC)
- Maximum switching voltage: 150VAC 24VDC
- Digital interface
- Control signal: TTL level
- Rated load: 8A 150VAC (NO) 10A 24VDC (NO), 5A 250VAC (NO/NC) 5A 24VDC (NO/NC)
- Maximum switching power: AC1200VA DC240W (NO) AC625VA DC120W (NC)
- Contact action time: 10ms
Connection Diagram
Firstly you need to prepare the following parts by yourself before testing.
- Arduino Board*1
- Single relay module*1
- LED module *1
- USB Cable*1
- Jumper Wire*8
Sample Code
Copy and paste the code below to Arduino software.
int Relay = 8; void setup() { pinMode(13, OUTPUT); //Set Pin13 as output digitalWrite(13, HIGH); //Set Pin13 High pinMode(Relay, OUTPUT); //Set Pin3 as output } void loop() { digitalWrite(Relay, HIGH); //Turn off relay delay(2000); digitalWrite(Relay, LOW); //Turn on relay delay(2000); }
Test Result
This relay module is active HIGH level.
Wire it up well, powered up, then upload the above code to the board.
You will see the relay is turned on(ON connected, NC disconnected)for two seconds, then turned off for two seconds(NC closed,ON disconnected), repeatedly and circularly.
When the relay is turned on, external LED is on. If relay is turned off, external LED is off.
Project 37: Vapor Sensor
Introduction:
Steam sensor is an analog sensor and can be made as a simple rainwater detector and liquid level switch. When humidity on the face of this sensor rises, output voltage will increase.
Caution: connection parts is non-waterproof, so please don’t put them into water.
Performance Parameters
- 1.Working Voltage: 3.3V or 5V
- 2.Working Current: <20mA
- 3.Range of Working Temperature: -10℃~+70℃
- 4.Interface Type: Analog Signal Output
Pin Definition:
- S:Signal Output
- +:Power Supply(VCC)
- -:Ground(GND)
Test Code
void setup() { Serial.begin(9600); //open serial port, and set baud rate at 9600bps } void loop() { int val; val=analogRead(0); //plug vapor sensor into analog port 0 Serial.print("Moisture is "); Serial.println(val,DEC); //read analog value through serial port printed delay(100); }
Result
When detecting different degrees of humidity, the sensor will get the feedback of different current value. Shown as the following picture.
When the sensor detects the steam of boiled water, the moisture value is displayed on serial monitor of Arduino software.
Resources
- Video:
http://video.keyestudio.com/KS0068/
- Libraries:
https://fs.keyestudio.com/KS0068