In the previous article, we have learned and made use of the Intel Galileo Development Board and Windows on device to create flame alarms, light sensors, and PWM dimming lights. In this project, we use the temperature sensor and the DC motor to complete a simple intelligent fan production.
1. Temperature sensor
LM35 is a very common and easy to use temperature sensor element, in the traditional Arduino project, only need a LM35 element and an analog interface can be achieved, the difficulty is that the algorithm will read the analog value into the actual temperature. But for Galileo, because the Galileo is more sensitive to noise and volatility, additional resistors and filter capacitors are required. Please refer to the Hardware Connection section below for details.
2. DC Motor
This is possible with the normal 5V DC motor, the key is that the Galileo has a limited drive capability and requires a transistor to drive the DC motor. Refer to the Hardware Connection section below for details.
3. Components and Hardware connections
The components to be used in this practice project are:
• Temperature sensor: LM35 One
5v DC Motor: A
• Resistance: 220 ohm, 330 ohm each
• Diode: One
• Transistor: 90,131 x
• Connection Cable: Several
• Bread PLATE: One Piece
1) connection of the temperature sensor
The LM35 has three pins, namely GND, Vout and VS, Connected, Galileo A0 and 5V pins. Here, a 220 ohm resistor is added between the vout input and the ground, and a 0.1uF ceramic capacitor is added near the pin of the LM35 power input to filter out the interference from the power supply.
2) connection of DC motor
Transistor 9013 Collector on the DC motor, with Galileo digital pin 11来 control the base of the transistor, the stage is directly grounded. It is important to note that a diode is placed at both ends of the DC motor for the release of the remaining energy after a power outage.
Finally, its hardware is connected as shown.
4. Principle of Experiment
Galileo the A0 mouth continuously collects the temperature, the return value is judged, if exceeds a certain range, opens the DC motor. If the temperature does not exceed the set value, turn off the DC motor. The process is as follows.
5. Source code Parsing
#include "stdafx.h"
#include "arduino.h"
int _tmain (int argc, _tchar* argv[])
{
return Runarduinosketch ();
}
int motor_pin = 11; Defining the Digital Interface 11 control DC motor
int temp_pin = A0; Defining the Analog interface 0 connecting the LM35 temperature sensor
void Init_motor ()
{
Pinmode (Motor_pin, OUTPUT);
Analogwrite (motor_pin, 0);
}
void Setup ()
{
Todo:add Your code here
Init_motor (); Initializing the DC motor control pin
}
The loop routine runs over and over again forever:
void Loop ()
{
Todo:add Your code here
int val;//Defining variables
int dat;//Defining variables
val = Analogread (Temp_pin);//Read the analog value of the sensor and assign a value to Val
DAT = (range * val) >> 8;//Temperature Calculation formula
Log (L "TEP:");
Log (L "%d", DAT);//display DAT variable value
Log (L "c\r\n");
if (Dat > 21)//temperature judgment, according to the actual situation set
{
Log (L "Start DC motor\r\n");
Analogwrite (Motor_pin, 100);
Delay (3000);
}
Else
{
Log (L "Stop DC motor\r\n");
Analogwrite (motor_pin, 0);
Delay (3000);
}
}
6. Debug results
Start Galileo, connect using Telnet, and then click Debug. The program will be downloaded to the Galileo via the network port. The fan does not turn before the temperature has reached the set threshold, and after the temperature is exceeded, the fans work. The debug picture is as follows.
Windows on Device Project Practice 4-Smart fan maker