Sensores Arduino Gen
Sensores Arduino Gen
Summary:
DIY Maker 37 IN 1 sensor learning package is a highly cost-Learning Arduino sensor package
We carefully build for the beginners, in the whole learning process without welding and wiring,
directly by plug 3P universal sensor cable, you can easily go to experience the fun of interactive
sensing and electronic technology, in getting started.
Let us into a variety of interactive electronic world. . .
SunFounder
list of kit:
01. DS18B20 sensor module
02. vibration switch module
03. Hall magnetic sensor module
04. key switch module
05 .infrared transmitter module
06 .passive buzzer module
07. laser transmitter module
08. 3 colors - Full Color LED SMD Module
09. photo interrupter module
10. 3 mm red and green LED module (common cathode)
011. active buzzer module
012. analog temperature sensor
013. DHT11 digital temperature and humidity sensor module
014,.3 colors - LED full color module
015. mercury tilt switch module
016. photoresistor module
017. 5V Relay Module
018. tilt switch module
019. MINI reed switch module
020. infrared receiver module
021. PS2 gamepad axis sensor module
022. Linear Hall magnetic module
023. Reed module
024. flame sensor module
025. Magic light cup module
026. Digital Temperature Module
027. 5mm red and green LED module (common cathode)
028. knock sensor module
029. infrared obstacle avoidance sensors
030. 7 color flashing LED module will automatically
031. analog Hall magnetic sensor module
032. Touch Module
033.High sensitivity sound detection module
034. microphone sound detection module
035. finger measuring heartbeat module
036.. Tracking Module
037. rotary encoder modules
SunFounder
List of courses
二, Products
As in the past the temperature sensor output is analog, we need to add additional A / D And D / A
chip into Line conversion, then for Arduino resources are not abundant external interface is a big
challenge at the same time Utilization is not high, then we The new DS18B20 Temperature Sensor
Module for a good solution to this Issues unique bus line And economic characteristics, fully
applicable Arduino platform that allows users to easily set up pass Sensor networks.
Third, the technical parameters
1, the module uses a single-bus digital temperature sensor DS18B20, the external power supply
voltage Range is 3.0 V to 5.5 V, No standby power. Measurement temperature range of -55 ° C to
+125 ℃, Fahrenheit equivalent 67 ° F to 257 ° F, -10 °C to +85 ° C range accuracy of ± 0.5 ° C.
2, the temperature sensor is a programmable resolution of 9 to 12 temperature conversion to 12-bit
digital format With a maximum of 750 milliseconds formula User definable nonvolatile
temperature alarm settings.
3, each DS18B20 contains a unique serial number, can be with a plurality ds18b20s Exists in a
bus. Temperature sensor can be placed at different places in the detected temperature.
IV Notes
1, because the ordinary transistor DS18B20 and looks similar, we'll be sure to note when using
Be careful not to regard it as a generalPass transistor used to avoid damage;
2, in order to prevent damage to the DS18B20 and makes it does not work, we should ensure that
the powerLine and ground not reversed.
3, the relevant technical data on the bus did not mention a single number that can be linked to how
much DS18B20, But in practical applications are not as many, and we should pay attention to.
4, there is a connection DS18B20 bus length limitations that should be taken in the long-distance
communication Consider bus distributed capacitance and resistance Impact resistant.
5, instructions for use Identify DS18B20 Temperature Sensor Module power lines, ground, and
data Lines, power lines, ground points connected to the Arduino test board +5 V, GND port
number Data bus connected to the digital port.
6, module function test
1, the hardware device
Arduino controller × 1
DS18B20 Temperature Sensor Module × 1
SunFounder
USB data cable × 1
Connect the circuit is very simple, as long as the connected module power supply, ground, and
then the module
Data bus
With Arduino digital pin connected to terminal 12 can be, even on the USB data Throughout the
test circuit is complete, DS18B20 test results we will use the serial port are displayed on the
computer screen. We will test the compiled code downloaded to the board, open the serial port can
know that we are What kind of temperatures in the Well, did not talk much, we first look at the test
code bar
# Include <OneWire.h>
/ * DS18S20 Temperature chip i / o
*/
OneWire ds (10); / / on pin 10
void setup (void) {
/ / Initialize inputs / outputs
/ / Start serial port
Serial.begin (9600);
}
void loop (void) {
byte i;
byte present = 0;
byte data [12];
byte addr [8];
int Temp;
if (! ds.search (addr)) {
ÿ / / Serial.print ("No more addresses. \ n");
ÿds.reset_search ();
ÿreturn;
}
Serial.print ("R ="); / / R = 28 Not sure what this is
for (i = 0; i <8; i + +) {
Serial.print (addr [i], HEX);
Serial.print ("");
}
if (OneWire :: crc8 (addr, 7)! = addr [7]) {
ÿSerial.print ("CRC is not valid! \ n");
ÿreturn;
}
if (addr [0]! = 0x28) {
ÿSerial.print ("Device is not a DS18S20 family device. \ n");
ÿreturn;
}
ds.reset ();
SunFounder
ds.select (addr);
ds.write (0x44, 1); ÿ / / start conversion, with parasite power on at the end
delay (1000); / / maybe 750ms is enough, maybe not
/ / We might do a ds.depower () here, but the reset will take care of it.
present = ds.reset ();
ds.select (addr);
ds.write (0xBE); ÿ / / Read Scratchpad
Serial.print ("P =");
Serial.print (present, HEX);
Serial.print ("");
for (i = 0; i <9; i + +) {ÿ / / we need 9 bytes
data [i] = ds.read ();
When you write the program, download it to arduino inside after running the resulting effect is as
follows: In the
When doing experiments here
The temperature was 27 degrees Celsius, touch DS18B20, you can see the serial communication
Significant change in the temperature of the module.
A success! ^ _ ^
VII Conclusion
This section here will come to an end, I believe after reading this section has not DS18B20
And then is so afraid of
It, in fact, as long as we grasp, we can use it arbitrary and designed our personality
Electronic products, their
Try it yourself also. . . . .
*******************************************************************************
SunFounder
02 ARDUINO vibration switch module
Vibration module and number 13 comes with interfaces to build a simple circuit LED, producing
vibrations flasher.
13 comes with digital interfaces of the LED, the shock sensor access number 3 interface, when a
sense of shock sensor
Measure
To a vibration signal, LED flashing light.
Routines source code:
int Led = 13 ;/ / define LED Interface
int Shock = 3 / / define the vibration sensor interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (Shock, INPUT) ;/ / output interface defines vibration sensor
}
void loop ()
{
val = digitalRead (Shock) ;/ / read digital interface is assigned a value of 3 val
if (val == HIGH) / / When the shock sensor detects a signal, LED flashes
{
digitalWrite (Led, LOW);
}
else
{
digitalWrite (Led, HIGH);
}
SunFounder
}
*******************************************************************************
Hall magnetic sensor module and a digital interface, built-in 13 LED build a simple circuit to
produce a magnetic flasher.
13 comes with digital interfaces of the LED, the Hall magnetic sensor connected to the force plate
number 3 ARDUINO interface
When the Hall magnetic sensor to a magnetic field signal, LED lights, lights off and vice versa.
}
With reference program:
int Led = 13 ;/ / define LED Interface
int SENSOR = 3 ;/ / define the Hall magnetic sensor interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (SENSOR, INPUT) ;/ / define the Hall magnetic sensor output interface
}
void loop ()
{
SunFounder
val = digitalRead (SENSOR) ;/ / read digital interface is assigned a value of 3 val
if (val == HIGH) / / When the shock sensor detects a signal, LED lights
{
digitalWrite (Led, HIGH);
}
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
Key switch module and a digital interface, built-in 13 LED build a simple circuit to produce key
warning lamp
13 comes with digital interfaces of the LED, the access number 3 button switch sensor interfaces,
when the key switch
Sensor senses a key signal, LED lights, otherwise off.
Routines source code:
int
Led = 13 ;/ / define LED Interface
int buttonpin = 3 / / define the key switch sensor interface
; Int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
SunFounder
pinMode (buttonpin, INPUT) ;/ / define the key switch 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 key switch when the sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
*******************************************************************************
06 Passive buzzer
Arduino can be done with a lot of interactive work, the most common and most commonly used is
the sound and light show in front has been
LED lights are used in the experiments, we let the experiment circuit sound, a voice of the most
common
Component is the buzzer and speaker, and comparison of the two buzzer easier and ease the
present study, we buzzer.
Buzzer and the principle
(A) the introduction of the buzzer
1. Buzzer Buzzer is an integrated role in the structure of electronic transducers, DC voltage power
supply, wide
Pan used in computers, printers, copiers, alarms, electronic toys, automotive electronic equipment,
telephones, timers, etc.
Electronic products for sound devices.
2. The classification is divided into buzzer piezo buzzer buzzer and two types of electromagnetic
SunFounder
buzzer.
3. Graphic symbols buzzer buzzer circuit in the circuit by the letter "H" or "HA" (old standard
with
"FM", "LB", "JD", etc.) indicates.
(Two) structural principle buzzer
1. Piezo Buzzer Piezo Buzzer mainly by the multivibrator, piezo buzzer, impedance matching and
resonance
Boxes, housing and other components. Some piezo buzzer case is also equipped with light-
emitting diodes.
Multivibrator constituted by the transistors or integrated circuits. When switched on (1.5 ~ 15V
DC working voltage), multi-
Harmonic oscillator start-up, the output 1.5 ~ 2.5kHZ audio signals, impedance matching push
piezo buzzer sound.
Piezo buzzer by a lead zirconate titanate or lead magnesium niobate piezoelectric ceramic
material. Both sides of the ceramic piece plated silver electrode
The polarization and the aging process, and then with brass or stainless steel sheet stick together.
2. Magnetic Buzzer Magnetic Buzzer by the oscillator, the electromagnetic coil, magnet,
diaphragm and housing and other components.
After power on, the audio signal generated by the oscillator current through the electromagnetic
coil, the electromagnetic coil generates a magnetic field. Shake
Moving the diaphragm in the electromagnetic coil and magnet interaction, periodically sound
vibration.
Active and passive buzzer buzzer What is the difference
Here the "source" does not mean power. But rather refers to the shock source. In other words, the
active internal buzzer with shock source, so only
Will be called to an energized.
The passive internal sources without shocks, so if a DC signal can not make it tweet. Must 2K ~
5K square wave to
Drive it.
Buzzer often than passive expensive, because there multiple oscillator circuit.
Passive buzzer advantages are: 1. Cheap, 2. Sound frequency control, you can make a "more than
a meter hair Suola Xi 'efficiency
Fruit. 3. In some special cases, you can reuse a control and LED port active buzzer advantages are:
process control
Convenient.
ARDUINO refer to the source:
int buzzer = 8 ;/ / setting controls the digital IO foot buzzer
void setup ()
{
pinMode (buzzer, OUTPUT) ;/ / set the digital IO pin mode, OUTPUT out of Wen
}
void loop ()
{
unsigned char i, j ;/ / define variables
SunFounder
while (1)
{
for (i = 0; i <80; i + +) / / Wen a frequency sound
{
digitalWrite (buzzer, HIGH) ;/ / send voice
delay (1) ;/ / Delay 1ms
digitalWrite (buzzer, LOW) ;/ / do not send voice
delay (1) ;/ / delay ms
}
for (i = 0; i <100; i + +) / / Wen Qie out another frequency sound
{
digitalWrite (buzzer, HIGH) ;/ / send voice
delay (2) ;/ / delay 2ms
digitalWrite (buzzer, LOW) ;/ / do not send voice
delay (2) ;/ / delay 2ms
}
}
}
After downloading the program, the buzzer experiments are done.
*******************************************************************************
13 laser transmitter module and a digital interface, built-in LED build a simple circuit as shown
below
SunFounder
Routines source code:
void setup ()
{
pinMode (13, OUTPUT); / / define the digital output interface 13 feet
}
void loop () {
digitalWrite (13, HIGH); / / open the laser head
delay (1000); / / delay one second
digitalWrite (13, LOW); / / turn off the laser head
delay (1000); / / delay one second
}
*******************************************************************************
I. Overview:
SMD RGB LED module consists of a full-color LED made by R, G, B three pin PWM voltage
input can be adjusted
Section three primary colors (red / blue / green) strength in order to achieve full color mixing
effect. Control of the module with the Arduino can be achieved
Cool lighting effects.
Second, the product parameters:
Product Features:
SunFounder
1, using 5050 full color LED
2, RGB trichromatic limiting resistor to prevent burnout
3, through the PWM adjusting three primary colors can be mixed to obtain different colors
4, with a variety of single-chip interface
5 Operating voltage: 5V
6.LED drive mode: common cathode driver
Three, Arduino test 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);
Serial.begin (9600);
}
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);
}
Serial.println (val, DEC);
*******************************************************************************
Photo interrupter module and a digital interface, built-in 13 LED build a simple circuit to produce
photo-interrupter warning lamp
13 comes with digital interfaces of the LED, the light blocking access number 3 sensor interfaces,
sensing when the light interrupter
Device senses a key signal, LED lights, otherwise off.
Routines source code:
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);
}
}
SunFounder
*******************************************************************************
*******************************************************************************
011.Buzzer Module
SunFounder
One, related presentations
I believe we are not unfamiliar to the buzzer, we will be used in many scenarios buzzer, most of
them
Prompted to do is to use the buzzer or alarm, such as button press, to work, or the end of the work
breakdown and so on.
Here the microcontroller drives the buzzer to make it on the application description.
Second, drive mode
Conventional drive the buzzer in two ways: one is the PWM output to directly drive, another is the
use of
I / O timing flip-level generates a drive waveform for the buzzer to drive.
PWM output PWM output to directly drive is to use a certain port itself can output square wave
drive directly
Moving the buzzer. In the SCM software settings, there are several system registers are used to set
the PWM output port,
You can set the duty cycle, period, etc. By setting these registers that meets the requirements of
the buzzer frequency waves
Shape, simply open the PWM output, PWM output port can output the frequency square wave,
this time Lee
This waveform can be driven with a buzzer. Such as frequency of 2000Hz
http://keyes-arduino.taobao.com
Buzzer driver, you can know the cycle of 500μs, so just put the PWM period is set to 500μs,
Duty level is set to 250μs, can generate a frequency of 2000Hz square wave, square wave through
reuse
You can go with a transistor drive the buzzer it.
The use of I / O timing flipping to generate drive waveform level would be more trouble that way,
you must use regularly
Timing is done, flip through the regular level that meets the requirements of the buzzer frequency
waveform This waveform can be
Be used to drive the buzzer. Such as 2500Hz buzzer driver, you can know the cycle of 400μs,
which
Samples only need to drive the buzzer I / O port flip once every 200μs level can generate a
frequency
2500Hz, 1/2duty duty square wave, and then through the transistor amplifier can drive the buzzer
it.
Third, the module uses
We look to the module should understand that he is very easy to use, a power supply terminal, a
ground terminal, as well as a
One is the signal input. We just put the power and ground connected, then the signal line
connected to IO ports on the line
Fourth, the module function test
Hardware Requirements
Arduino controller × 1
SunFounder
USB data cable × 1
Buzzer Module × 1
Adjustable potentiometer (10K) × 1
The following test examples we mainly learn how to control the buzzer sound, and some simple
applications, of course,
Using two different drivers drive the buzzer sound, we can compare the next effect a convenient
future use.
Here are the specific connection
Here's the test code is a buzzer on the use of analog control display frequency of the procedure:
Program Description: The first 10-pin to control the buzzer pin.
3 pin to analog pin, the use of adjustable resistor is 10K.
Function: to mobilize adjustable resistor can hear the buzzer sounds obvious frequency changes.
int speakerPin = 8 ;/ / control horn pin
int potPin = 4 ;/ / control pin adjustable resistor
int value = 0;
void setup () {
pinMode (speakerPin, OUTPUT);
}
void loop () {
value = analogRead (potPin); reading resistor values pin
digitalWrite (speakerPin, HIGH);
delay (value); adjust the speaker sound of the time;
digitalWrite (speakerPin, LOW);
delay (value); adjust the speaker does not ring a time;
}
Here we can say that the delay adjustment potentiometer to achieve the effect of different times,
thus changing the buzzer
Audible frequency, we can try to see in the end is not like that, ah ~ ~ ~ ~
Here we added a key switch to control the buzzer, so that we can simulate a simple doorbell, when
you press
Key is pressed, the speaker can make any noise.
Physical connections are as follows:
Sample code:
const int buttonPin = 4; / / button pin;
const int speakerPin = 8; / / buzzer pin;
/ / Variables will change:
int buttonState = 0; / / read the key pin a value
void setup ()
{
/ / Set button pin to input mode, the buzzer pin output mode;
pinMode (speakerPin, OUTPUT);
pinMode (buttonPin, INPUT);
}
void loop () {
SunFounder
/ / Read the key one initial value, where I took in the circuit is in the default high, the initial value
is high;
buttonState = digitalRead (buttonPin);
/ * If the key is high, then the buzzer did not ring;
Because I just began to take in the hardware circuit initial value is high, so the if condition is true,
the buzzer does not sound
*/
if (buttonState == HIGH) {
digitalWrite (speakerPin, LOW);
}
else {
/ / This button is low (also the key is pressed); buzzer sounded
digitalWrite (speakerPin, HIGH);
}
}
This procedure is relatively simple, I believe we see to understand, in order to increase people's
awareness on the honey me great
Home to write a short code with PWM control buzzer.
The following procedure is to use a PWM (pulse width modulation) control the buzzer, and
downloaded to the microcontroller can be heard
Buzzer sounded a different tone, as long as we adjust the notes under the relevant tracks
(0,1,2,3,4,5,6,7) can make the beep
Is sing.
Procedures are as follows:
int speakerPin = 8;
byte song_table [] = {30, 30, 30, 40, 50, 60, 70, 80, 90, 100,110, 120, 130, 140,
150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 250, 240, 230, 220, 210, 200, 190, 180,
170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 30, 30};
int MAX = 50;
int count = 0;
void setup () {
pinMode (speakerPin, OUTPUT);
}
void loop () {
analogWrite (speakerPin, song_table [count]);
count + +;
if (count> MAX) {
count = 0;
}
delay (50);
}
The physical connection is available on specific cases.
V. Conclusion
As the buzzer control is relatively simple, we do not do too much introduction, we will use the
SunFounder
line, of course, we
The above test case is relatively rough, buzzer sound effect may not be very good, with readers
slowly comprehend. . . . .
*******************************************************************************
*******************************************************************************
I. Overview:
RGB LED module consists of a plug-in full color LED made by R, G, B three pin PWM voltage
input can be adjusted
Section three primary colors (red / blue / green) strength in order to achieve full color mixing
effect. Control of the module with the Arduino can be achieved
Cool lighting effects.
Second, the product parameters:
Product Features:
1, the use of plug-in full-color LED
2, RGB trichromatic limiting resistor to prevent burnout
3, through the PWM adjusting three primary colors can be mixed to obtain different colors
4, with a variety of single-chip interface
SunFounder
5, the working voltage: 5V
6, LED drive mode: common cathode driver
Three, Arduino test 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);
Serial.begin (9600);
}
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);
}
Serial.println (val, DEC);
}
*******************************************************************************
Mercury switch module and a digital interface, built-in 13 LED build a simple circuit to produce
tilt warning lamp
13 comes with digital interfaces of the LED, the mercury tilt switch sensor interface to access
digital 3, when the water
Silver tilt switch sensor senses a key signal, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the mercury tilt switch sensor interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / define the mercury tilt switch sensor output interface
http://keyes-arduino.taobao.com
}
void loop ()
{
val = digitalRead (buttonpin) ;/ / read the values assigned to the digital interface 3 val
if (val == HIGH) / / When the mercury tilt switch sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
SunFounder
*******************************************************************************
I. Introduction
Photoresistor in our daily lives but also be able to see, is mainly used in smart switch, giving our
students
Live brings some convenience, but, in our daily electronic design will also be used. Then in order
to make better use,
We have the appropriate module, easy to use, and efficient.
Second, an overview
Photoresistors are semiconductor photosensitive devices, in addition to having high sensitivity,
fast response, consistent with the spectral characteristics and value of r
Good features, but at a high temperature, and humidity in harsh environments, but also to maintain
a high degree of stability and reliability, wide
Pan used cameras, solar garden lights, lawn, detectors, clock, music, cups, gift boxes, mini-
Night light, light voice switches, lights automatically switch toys and a variety of light control,
light control lighting, lamps and other light automatic opening
OFF control field
Third, the main parameters and characteristics
1, according to the spectral characteristics of the photoresistor has three photoresistor: Ultraviolet
photosensitive resistance, infrared light-sensitive resistors,
Visible photosensitive resistance;
2, the main parameters are as follows:
A, dark current, dark resistance: photosensitive resistance at a certain applied voltage, when the
light is not irradiated when the flowing
Current is called dark current. Applied voltage and dark current ratio as the dark resistance;
SunFounder
B, Sensitivity: Sensitivity is irradiated by light sensitive resistor, the resistance value (dark
resistance) when irradiated with light
Resistance value (light resistance) the relative change in values.
C, volt-ampere characteristic curve. Voltage characteristic curves are used to describe the
resistance of the applied voltage and the photosensitive photocurrent relationship,
On the photosensitive devices, the light current with applied voltage increases.
D, temperature coefficient. Photoelectric effect photoresistor affected by temperature, at a low
temperature portion photoresistor photoelectric
Sensitive high sensitivity at high temperatures is low.
E, rated power. Photosensitive resistor rated power is allowed for certain lines in the power
consumed when the temperature rise
High, its power consumption is reduced.
Fourth, the use
Because we are in the Arduino environment, then we take a look at how they are connected to the
corresponding
And general sensors, two power lines and a data cable, wiring is simple;
Then our subsequent test circuit wiring can be like it. Well, since the wiring will be, we take a
look at the following
In the end how to use it.
Five, module test
Hardware Requirements
1, Arduino controller × 1
2, USB data cable × 1
3, the photosensitive resistor module × 1
int sensorPin = 2;
int value = 0;
void setup () {
Serial.begin (9600);
}
void loop () {
value = analogRead (sensorPin);
Serial.println (value, DEC);
delay (50);
}
Well, the next test code
We then tested the photoresistor just read the module's output analog voltage value, the test
results, we find that when
There is light, the output voltage is high, the equivalent of the switch is turned on, but there is no
light, the output voltage is low, the equivalent of switching off
Open, in practical applications can use this point.
Below are bright and dull when compared to the output data:
The data window is positioned above the light, the following is the data light;
SunFounder
*******************************************************************************
I. Introduction
At present, the company's products have multiple types of relays, including a relay, two relays, 4
relay,
6 relay, 8 relays, etc., to meet the needs of different users use the relay is when the input
(excitation
Reed amount) meet the requirements change, the output circuit in the electrical manipulation
occurred predetermined amount charged a step change in an electrical
Makers. The company produces relay module can be connected to 240V AC or 28V DC power
into a variety of other electrical parts
Line control. Can be achieved using single-chip timing control switching purposes. Can be used in
anti-theft alarm, toys, building
Let other fields. Relay is an electrically controlled device. It has a control system (also known as
the input circuit) and the control system
(Also known as the output circuit) the interaction between. Commonly used in automation control
circuit, it is actually a small
Current to control a large current operation "automatic switch." Therefore, the circuit
automatically adjusts the play, safety protection, transfer
Conversion circuit and so on. Particularly suitable for single-chip control strong electric devices.
In the control and use is also very convenient, just give input corresponding output relay different
levels, you can
Achieved by controlling the relay control purposes other devices, in addition, in the multi-channel
SunFounder
relay PCB layout on the use of two lines
Layout, user-lead connections. While in the circuit of a DC diode added greatly improved relay
Module to engage current ability to prevent the transistor being burned. In addition, we added a
relay this power indicator
Lights (except relay all the way), the indicator is red. In brightest relay also adds a status indicator.
Can
To let everyone real-time observation of the relay switch status.
Second, the module classification introduced
1, one relay
A, the main purpose
Relay is a function of the automatic isolation switching elements, are widely used in remote
control, telemetry, communications, automatic control,
Mechatronics and power electronic devices, is one of the most important control elements.
Boils down to the following effect:
1) expand the control range: for example, multi-contact relay control signal reaches a certain
value, you can not press the contact group
Different forms, and for access, breaking, connected multi-channel circuits.
2) Zoom: for example, sensitive relays, relays, etc., with a very small amount of control, you can
control a large
The power of the circuit.
3) Integrated signal: for example, when a plurality of control signals in the form prescribed input
multi-winding relay, by comparison mechanized
Together, to achieve the desired control effect.
4) automatic, remote control and monitoring: for example, the automatic device relays together
with other appliances, can be composed of program control
Wire line, in order to achieve automatic operation
B, Note
1) Rated voltage: refers to normal working hours relay coil voltage required,
The control circuit is a control voltage. According to the relay model, can be ac
Pressure, it can be a DC voltage.
2) DC resistance: refers to the relay coil DC resistance, measured by the multimeter.
3) Pick-up current: refers to the relay pull action can produce a minimum current. In normal use,
the current will be given
Be slightly larger than the pull current, so that the relay can be operated stably. The work of the
coil voltage is applied, generally do not
To more than 1.5 times the rated working voltage, otherwise it will have a greater current to the
coil burnt.
4) release current: refers to the relay generates the maximum current release action. When the
relay state current is reduced to a
Certain extent, the relay will revert to the release of unpowered state. Then the current is much
smaller than the pull current.
5) contact switch voltage and current: is the relay to allow the applied voltage and current. It
determines the relay to control
Voltage and current size, use can not exceed this value, it will be very easy to damage the relay
SunFounder
contacts.
C, module test
Pin Description below
Description: COM to VCC, NO then we have to control the LED anode, which
Like when the relay turns on, LED lights will be lit;
To complete the look of this test must be prepared to what what they specifically
Arduino controller × 1
USB data cable × 1
1 relay module × 1
Led indicator × 1
The resistance of the resistance 330 × 1
Of course, we have the following physical connections for a specific reference
Well, Here is a simple relay control test procedure:
int relay = 10; / / relay turns trigger signal - active high;
http://keyes-arduino.taobao.com
void setup ()
{
pinMode (relay, OUTPUT); / / Define port attribute is output;
}
void loop ()
{
digitalWrite (relay, HIGH); / / relay conduction;
delay (1000);
digitalWrite (relay, LOW); / / relay switch is turned off;
delay (1000);
}
Program Description: The program notes in the conduction and disconnection refers to the way
that we want that we are using the NO side,
When S relay switches into high and hit the NO side, the switch is turned on, connected to the
LED will be lit, otherwise the switch
Hit the NC side, NO direction disconnect, LED light goes out;
You will see the test results led lights flashing interval 1s;
*******************************************************************************
Tilt switch module and a digital interface, built-in 13 LED build a simple circuit to produce tilt
warning lamp
13 comes with digital interfaces of the LED, the tilt switch sensor interface to access digital 3,
when the tilt open
Off sensor senses a key signal, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the tilt switch sensor interfaces
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / define the output interface tilt switch sensor
}
void loop ()
{
val = digitalRead (buttonpin) ;/ / digital interface will be assigned a value of 3 to read val
if (val == HIGH) / / When the tilt sensor detects a signal when the switch, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
SunFounder
019 MINI reed switch module
Reed module and the interface comes with digital 13 LED build a simple circuit to produce a Reed
warning lamp
13 comes with digital interfaces of the LED, the Reed sensor access number 3 interface, when
Reed sensors
Sensed a key signal, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the Reed sensor interfaces
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / output interface as defined Reed sensor
}
void loop ()
{
val = digitalRead (buttonpin) ;/ / digital interface will be assigned a value of 3 to read val
if (val == HIGH) / / When the Reed sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
SunFounder
}
}
*******************************************************************************
I. Introduction
This is a new ultra-thin 38K universal infrared remote control, using the NEC encoding format,
mainly for cars
Containing MP3, foot bath, lighting design equipped, digital photo frame, microcontroller
development board learning board and other occasions. Because it is based on non-
Line remote control, so people seem easy to use, effective, and now more and more wide
application field, then for
This product of our company that we will make the following introduction.
Second, the technical parameters
Infrared remote control distance: more than 8 meters
Launch tube infrared wavelength: 940Nm
Crystal frequency: 455KHZ crystal
SunFounder
Carrier frequency: 38KHZ
Encoding: encoding format for the NEC
Size: 86 * 40 * 6mm
Power: CR2025/1600mAH
Third, the use
We must remember that before using the remote control to the infrared cell, as well as infrared
remote control infrared receiver module allows to combine
Use, which is responsible for receiving infrared remote control transmitter over the information
and decodes it into hexadecimal code, so as to achieve
Established communications.
The infrared receiver module with Arduino properly connected, where S connection D11, VCC
connected +5 V, GND connected GND, and
To be fixed;
Here is its connection with the Arduino specific circuit
Fourth, the module test
1, Arduino controller × 1
2, USB data cable × 1
-3, Infrared remote control × 1
4, the infrared receiver module × 1
Accordance with the instructions connected test circuit,
Well, take a good circuit, then here we start testing it
In this test we will be encoded in the corresponding keys Serial Monitor window displays
Look at the test code:
# Include <IRremote.h>
int RECV_PIN = 11; / / define input pin on Arduino
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
}
}
Compiled the above code, we can download the test, pay attention before the test to make sure the
remote control has Shanghao
Battery! Here are some test results
In the testing process should pay attention to the infrared remote control and infrared receiver
position, making sure the infrared remote receiver can be well received
http://keyes-arduino.taobao.com
SunFounder
- Controller transmitting signals over; by the test results can be seen each key has its own
hexadecimal encoding, if I
We long press a button in the Serial Monitor window shows FFFFFFFF.
*******************************************************************************
*******************************************************************************
Linear Hall magnetic module and a digital interface, built-in 13 LED build a simple circuit to
produce a magnetic field warning lamp
13 comes with digital interfaces of the LED, the linear Hall sensor magnetometer access number 3
interface, when linear Hall magnetometer
Sensor senses a key signal, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the linear Hall magnetic sensor interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / define linear Hall magnetic 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 linear Hall sensor detects a magnetic signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
SunFounder
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
Reed module and the interface comes with digital 13 LED build a simple circuit to produce a Reed
warning lamp
13 comes with digital interfaces of the LED, the Reed sensor access number 3 interface, when
Reed sensors
Sensed a key signal, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the Reed sensor interfaces
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / output interface as defined Reed sensor
}
void loop ()
SunFounder
{
val = digitalRead (buttonpin) ;/ / digital interface will be assigned a value of 3 to read val
if (val == HIGH) / / When the Reed sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
Flame module Interface module and number 13 comes with LED build a simple circuit to produce
flame warning lamp
13 comes with digital interfaces of the LED, the flame sensor connected digital three interfaces,
when the flame sensor senses
There are key signal detected, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the flame sensor interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / output interface defines the flame sensor
SunFounder
}
void loop ()
{
val = digitalRead (buttonpin) ;/ / digital interface will be assigned a value of 3 to read val
if (val == HIGH) / / When the flame sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
Magic Light Cup modules are easy to Interactive Technology Division developed a can and
ARDUINO interactive modules,
PWM dimming principle is to use the principle of two modules brightness changes.
Mercury switches provide a digital signal that triggers the PWM regulator, through the program
design,
We can see the light like two cups filled with the effect of shuffling back and forth.
Attach ARDUINO code
SunFounder
int LedPinA = 5;
int LedPinB = 6;
int ButtonPinA = 7;
int ButtonPinB = 4;
int buttonStateA = 0;
int buttonStateB = 0;
int brightness = 0;
void setup ()
{
pinMode (LedPinA, OUTPUT);
pinMode (LedPinB, OUTPUT);
pinMode (ButtonPinA, INPUT);
pinMode (ButtonPinB, INPUT);
}
void loop ()
{
buttonStateA = digitalRead (ButtonPinA);
if (buttonStateA == HIGH && brightness! = 255)
{
brightness + +;
}
buttonStateB = digitalRead (ButtonPinB);
if (buttonStateB == HIGH && brightness! = 0)
{
brightness -;
}
analogWrite (LedPinA, brightness); / / A few Guan Yuan (ii)? analogWrite (LedPinB, 2
55 - brightness); / / B Yuan (ii) a few Bang? Delay (25);
}
Note: This experiment requires two modules simultaneously, so buy this product is to purchase
two groups
*******************************************************************************
Digital temperature module and a digital interface, built-in 13 LED build a simple circuit, making
the temperature warning lamp
13 comes with digital interfaces of the LED, the digital temperature sensor connected digital three
interfaces, when the digital temperature
Sensor senses a key signal, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the digital temperature sensor interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / define digital temperature 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 digital temperature sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
*******************************************************************************
13 knock sensor module and a digital interface, built-in LED build a simple circuit to produce
percussion flasher.
13 Interface comes with digital LED, will knock sensor connected digital 3 interface, when
percussion sensor senses
Measure
To percussive signals, LED flashing light.
Routines source code:
int Led = 13 ;/ / define LED Interface
int Shock = 3 / / define the percussion Sensor Interface
int val ;/ / define numeric variables val
SunFounder
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (Shock, INPUT) ;/ / define knock sensor output interface
}
void loop ()
{
val = digitalRead (Shock) ;/ / read digital interface is assigned a value of 3 val
if (val == HIGH) / / When the percussion when the sensor detects a signal, LED flashes
{
digitalWrite (Led, LOW);
}
else
{
digitalWrite (Led, HIGH);
}
}
*******************************************************************************
Infrared obstacle avoidance sensor is designed for the design of a wheeled robot obstacle
avoidance sensor distance adjustable. This ambient light sensor
Adaptable, high precision, having a pair of infrared transmitter and receiver, transmitter tubes emit
a certain frequency of infrared,
When detecting the direction of an obstacle (reflector), the infrared receiver tube receiver is
SunFounder
reflected back, when the indicator is lit,
Through the circuit, the signal output interface output digital signal that can be detected by means
of potentiometer knob to adjust the distance, the effective distance
From 2 ~ 40cm, working voltage of 3.3V-5V, operating voltage range as broad, relatively large
fluctuations in the power supply voltage of the situation
Stable condition and still work for a variety of microcontrollers, Arduino controller, BS2
controller, attached to the robot that
Can sense changes in their surroundings.
Specifications:
1 Working voltage: DC 3.3V-5V
(2) Working current: ≥ 20mA
(3) Operating temperature: -10 ℃ - +50 ℃
4 detection distance :2-40cm
5.IO Interface: 4-wire interfaces (- / + / S / EN)
6 Output signal: TTL level (low level there is an obstacle, no obstacle high)
7. Adjustment: adjust multi-turn resistance
8 Effective angle: 35 °
7 Size: 28mm × 23mm
8 Weight Size: 9g
Here we use the obstacle avoidance module and a digital interface, built-in 13 LED build a simple
circuit, making avoidance warning lamp, the obstacle avoidance
Sensor Access Digital 3 interface, when obstacle avoidance sensor senses a signal, LED light, and
vice versa off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define the obstacle avoidance sensor interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / define the obstacle avoidance 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 obstacle avoidance sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
SunFounder
}
*******************************************************************************
7 color flashing LED module automatically uses 5mm round high-brightness light-emitting diode
which has the following characteristics:
1) Product Type: LED
2) Product Model: YB-3120B4PnYG-PM
3) Shape: Round LED 5mm DIP type
4) Color: pink yellow green (high brightness)
5) Lens type: white mist
6) Standard Forward Voltage :3.0-4 .5 V
Arduino test cod:
/*
Blink
Turns on an LED on for two second, then off for two second, repeatedly.
This example code is in the public domain.
*/
void setup () {
SunFounder
/ / Initialize the digital pin as an output.
/ / Pin 13 has an LED connected on most Arduino boards:
pinMode (13, OUTPUT);
}
void loop () {
digitalWrite (13, HIGH); / / set the LED on
delay (2000); / / wait for a second
digitalWrite (13, LOW); / / set the LED off
delay (2000); / / wait for a second
}
*******************************************************************************
Analog magnetic sensor module and a digital interface, built-in 13 LED build a simple circuit to
produce a magnetic flash
Makers.13 comes with digital interfaces of the LED, the analog magnetic sensor connected to the
power board analog 5 ARDUINO Interfaces, when analog magnetic sensor to a signal, LED lights,
otherwise the lights out.
With reference program:
int sensorPin = A5; / / select the input pin
int ledPin = 13; / / select the pin for the LED
int sensorValue = 0; / / variable to store the value coming from the
sensor
void setup () {
SunFounder
pinMode (ledPin, OUTPUT);
Serial.begin (9600);
}
void loop () {
sensorValue = analogRead (sensorPin);
digitalWrite (ledPin, HIGH);
delay (sensorValue);
digitalWrite (ledPin, LOW);
delay (sensorValue);
Serial.println (sensorValue, DEC);
}
*******************************************************************************
Metal Touch Interface module and number 13 comes with LED build a simple circuit to produce a
touch cue lights
13 comes with digital interfaces of the LED, the metal touch sensor connected digital three
interfaces, when a metal touch
Sensor senses a key signal, LED lights, otherwise off.
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define Metal Touch Sensor Interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / define metal touch sensor output interface
SunFounder
}
void loop ()
{
val = digitalRead (buttonpin) ;/ / digital interface will be assigned a value of 3 to read val
if (val == HIGH) / / When the metal touch sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
*******************************************************************************
*******************************************************************************
This project uses bright infrared (IR) LED and a phototransistor to detect the pulse of the finger, a
red LED flashes with each pulse.
Pulse monitor works as follows: The LED is the light side of the finger, and phototransistor on the
other side of the finger, phototransistor used to obtain the flux emitted, when the blood pressure
pulse by the finger when the resistance of the phototransistor will be slight changed.
The project's schematic circuit as shown,
We chose a very high resistance resistor R1, because most of the light through the finger is
absorbed, it is desirable phototransistor sensitive enough. Resistance can be selected by
experiment to get the best results.
The most important is to keep the shield stray light into the phototransistor. For home lighting that
is particularly important because the lights at home mostly based 50HZ or 60HZ fluctuate, so faint
heartbeat will add considerable noise.
void setup ()
{
pinMode (ledPin, OUTPUT);
Serial.begin (115200);
}
SunFounder
void loop ()
{
static double oldValue = 0;
static double oldChange = 0;
int rawValue = analogRead (sensorPin);
double value = alpha * oldValue + (1 - alpha) * rawValue;
Serial.print (rawValue);
Serial.print (",");
Serial.println (value);
oldValue = value;
delay (period);
}
*******************************************************************************
LED lights use 13 PIN and Tracking sensor combines to make a warning light
Routines source code:
int Led = 13 ;/ / define LED Interface
int buttonpin = 3; / / define Tracking Sensor Interface
int val ;/ / define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ;/ / define LED as output interface
pinMode (buttonpin, INPUT) ;/ / define Tracking sensor output interface
}
void loop ()
{
val = digitalRead (buttonpin) ;/ / digital interface will be assigned a value of 3 to read val
SunFounder
if (val == HIGH) / / When the Tracking sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else
{
digitalWrite (Led, LOW);
}
}
*******************************************************************************
By rotating the rotary encoder can be counted in the positive direction and the reverse direction
during rotation of the output pulse frequency, unlike rotary potentiometer counter, which
Species rotation counts are not limited. With the buttons on the rotary encoder can be reset to its
initial state, that starts counting from 0.
How it works: incremental encoder is a displacement of the rotary pulse signal is converted to a
series of digital rotary sensors. These pulses are used to control
Angular displacement. In Eltra angular displacement encoder conversion using a photoelectric
scanning principle. Reading system of alternating light transmitting window and the window is
not
Consisting of radial indexing plate (code wheel) rotating basis, while being an infrared light
source vertical irradiation light to the code disk image onto the receiving
On the surface. Receiver is covered with a diffraction grating, which has the same code disk
window width. The receiver's job is to feel the rotation of the disc
Resulting changes, and change the light into corresponding electrical changes. Then the low-level
signals up to a higher level, and generates no interference
SunFounder
Square pulse, which must be processed by electronic circuits. Reading systems typically employ a
differential manner, about the same but the phase difference of the two waveforms
Different by 180 ° compared to the signal in order to improve the quality and stability of the
output signal. Reading is then the difference between the two signals formed on the basis,
Thus eliminating the interference.
Incremental encoder
Incremental encoders give two-phase square wave, the phase difference between them 90 °, often
referred to as A and B channels. One of the channels is given and speed-related
Information, at the same time, by sequentially comparing two channel signals, the direction of
rotation of the information obtained. There is also a special signal called Z or
Zero channel, which gives the absolute zero position encoder, the signal is a square wave with the
center line of channel A square wave coincide.
Clockwise counterclockwise
AB
11
01
00
10
AB
11
10
00
01
Incremental encoder accuracy depends on the mechanical and electrical two factors, these factors
are: Raster indexing error, disc eccentricity, bearing eccentricity, e-reading
Several means into the optical portion of the errors and inaccuracies. Determine the encoder
resolution is measured in electrical degrees, the encoder accuracy depends
Set the pulse encoder generates indexing. The following electrical degrees with a 360 ° rotation of
the shaft to said machine, and rotation of the shaft must be a full week of
Period. To know how much electrical equivalent of the mechanical angle of 360 degrees can be
calculated with the following formula: Electrical 360 = Machine 360 ° / n ° pulses / revolution
Figure: A, B commutation signals
Encoder indexing error is the electrical angle of the unit two successive pulse maximum offset to
represent. Error exists in any encoder, which
Is caused by the aforementioned factors. Eltra encoder maximum error is ± 25 electrical degrees
(declared in any condition), equivalent to the rated
Offset values ± 7%, as the phase difference 90 ° (electrical) of the two channels of the maximum
deviation ± 35 electrical degrees is equal to ± 10% deviation left Ratings
Right.
UVW incremental encoder signals
In addition to the conventional encoder, there are some other electrical output signal with
integrated incremental encoder. And UVW signals
The integrated incremental encoder that instance, it is usually applied to the AC servo motor
feedback. These magnetic signals generally appear in the AC servo motor
SunFounder
Machine, UVW through the simulation of the magnetic signal is generally of the original function
and design. In Eltra encoder, these optical signals are UVW
Methods of generating, and three square wave form, are offset from each other 120 °. In order to
facilitate starting the motor, the control of the starter motor to be
To these the correct signal. The UVW poles in the machine axis rotation pulses repeated many
times, because they directly depend on the connected electrical
Machine number of poles, and for 6 or more pole motor UVW signal.
**************************************************
*****************************************
ARDUINO test code:
int redPin = 2;
int yellowPin = 3;
int greenPin = 4;
int aPin = 6;
int bPin = 7;
int buttonPin = 5;
int state = 0;
int longPeriod = 5000; / / Time at green or red
int shortPeriod = 700; / / Time period when changing
int targetCount = shortPeriod;
int count = 0;
void setup ()
{
pinMode (aPin, INPUT);
pinMode (bPin, INPUT);
pinMode (buttonPin, INPUT);
pinMode (redPin, OUTPUT);
pinMode (yellowPin, OUTPUT);
pinMode (greenPin, OUTPUT);
}
void loop ()
{
count + +;
if (digitalRead (buttonPin))
{
setLights (HIGH, HIGH, HIGH);
}
else
{
int change = getEncoderTurn ();
int newPeriod = longPeriod + (change * 1000);
if (newPeriod> = 1000 && newPeriod <= 10000)
{
longPeriod = newPeriod;
SunFounder
}
if (count> targetCount)
{
setState ();
count = 0;
}
}
delay (1);
}
int getEncoderTurn ()
{
/ / Return -1, 0, or +1
static int oldA = LOW;
static int oldB = LOW;
int result = 0;
int newA = digitalRead (aPin);
int newB = digitalRead (bPin);
if (newA! = oldA | | newB! = oldB)
{
/ / Something has changed
if (oldA == LOW && newA == HIGH)
{
result = - (oldB * 2 - 1);
}
}
oldA = newA;
oldB = newB;
return result;
}
int setState ()
{
if (state == 0)
{
setLights (HIGH, LOW, LOW);
targetCount = longPeriod;
state = 1;
}
else if (state == 1)
{
setLights (HIGH, HIGH, LOW);
targetCount = shortPeriod;
state = 2;
}
else if (state == 2)
SunFounder
M
N
N