23
Crowtail-MOSFET enables you to control high voltage items (such as 50VDC) and low voltages
(such as 5V) on a microcontroller. A MOSFET is also a switch. There are two screw terminals on the
board. One for input power and the other for the device you want to control. Crowtail-MOSFET
transfers power from one end to the other when closed. However, if there is no external power
source, your device can still get power from the microcontroller through the Crowtail interface.
Similar to relays, MOSFET is often used in automatic control systems. It uses a small power source
to control a large power source so that our electricity can be controlled more safely and conveniently.
In this lesson, we will use MOSFET and motor to make a PWM controlled fan, so that we can control
the speed of the fan as we want!
DHT.h is a library based on temperature and humidity sensors. It contains multiple dht temperature
and humidity sensors, such as dht11, dht22 and other sensors, so we will use the built-in function to
read the temperature and humidity values.
The macro defines a DHT type. Because DHT.h contains libraries for multiple DHT sensors, we need
to tell the program which type of DHT sensor we need to use when we create an instance object for
DHT.
DHT type: #define DHTTYPE DHT11.
The role of is isnan() to determine whether the number in the brackets is a number. Isnan() is a short
of “is not a number”, if the number in the parentheses is not a number, it returns TRUE, otherwise, it
returns FALSE.
Isnan(): if (isnan(t) || isnan(h)) {}
The prototype for creating a DHT instance object is DHT name (uin8_t pin, uin8_t type, uin8_t count).
The “pin” represents the pin of the DHT sensor connected to the Arduino. The “type” represents the
type of the DHT sensor. Our Crowtail–Temperature & Humidity Sensor uses DHT11. The “count” is
an optional parameter.
Lesson 11 – PWM control
Introduction
Create DHT instance: DHT dht(DHTPIN, DHTTYPE);
The prototype for creating a DHT instance object is DHT name (uin8_t pin, uin8_t type, uin8_t count).
The “pin” represents the pin of the DHT sensor connected to the Arduino. The “type” represents the
type of the DHT sensor. Our Crowtail–Temperature & Humidity Sensor uses DHT11. The “count” is
an optional parameter.
Read humidity and temperature: float h = dht.readHumidity();
float t = dht.readTemperature();
Содержание Crowtail
Страница 48: ......