setrdate.blogg.se

Controlling a dc motor with 2n2222a transistor
Controlling a dc motor with 2n2222a transistor














You need to add “dht library” to work with DHT11 sensor. To make it work (according to written code), you have to connect LCD pins like this : Lcd.print(temp) // Printing temperature on LCD So if we need to generate 20% of duty cycle then we pass 255/5 value as PWM in “analogWrite” Function. And in loop by using dht function reads DHT sensor and then using some dht functions we extract temperature and display these on LCD.Īfter this we compare the temperature with pre define temperature digit and then generate PWM according to the temperature value.įor generating PWM we have used “analogWrite(pin, PWM value)” fuction in 8 bit. Mean if PWM value is equivalent of analog value. Then initialize all the things in setup loop.

Controlling a dc motor with 2n2222a transistor code#

If you are looking for something simple and more cost-effective you can check out the temperature controlled LED using LM35 and Temperature controlled Automatic AC switch projects, both of them are very easy to built and does not need a microcontroller.Īrduino Code for temperature-controlled fanįirst, we include the library for LCD and DHT sensor and then define pin for lcd, dht sensor and for fan. Digital pin 9 is used for controlling fan speed through the transistor. And a DHT11 sensor module is also connected to digital pin 12 of Arduino. Pins of LCD namely RS, EN, D4, D5, D6 and D7 are connected to Arduino digital pin number 7, 6, 5, 4, 3 and 2. LCD is directly connected to Arduino in 4-bit mode (Check this tutorial for more details: LCD Interfacing with Arduino Uno). Suppose we have a pule with duty cycle 50% that means it will give half of voltage that we apply.Īrduino Temperature Controlled Fan Circuit DiagramĬonnections of this temperature controlled fan circuit is very simple, here a liquid crystal display is used for displaying temperature and Fan speed Status. The main game of PWM is digital pulse with some duty cycle and this duty cycle is responsible for controlling the speed or voltage. (To understand more about PWM, check this circuit: 1 Watt LED Dimmer) This concept is used in the project to control the voltage using PWM.

controlling a dc motor with 2n2222a transistor

To understand it more simply, if you are applying 5 volt for driving a motor then motor will moving with some speed, now if we reduces applied voltage by 2 means we apply 3 volts to motor then motor speed also decreases. What is PWM? PWM is a technique by using we can control the voltage or power.

controlling a dc motor with 2n2222a transistor

Then transistor creates a voltage according to the PWM input.įan speed and PWM values and duty cycles values are showing in given table We have created PWM at pwm pin of arduino and applied it at base terminal of the transistor. Here we have only used this DHT sensor for sensing temperature, and then programmed our arduino according to the requirements. Here in this project, we have used a sensor module namely DHT11 that already has discuss our previous project namely “ Humidity and Temperature Measurement using Arduino”. And last part of system shows humidity and temperature on LCD and Fan driver. The second section reads the dht11 sensor module’s output and extracts temperature value into a suitable number in Celsiu s scale and control the fan speed by using PWM.

controlling a dc motor with 2n2222a transistor

One senses the temperature by using humidity and temperature sensor namely DHT11. The following are the materials required to perform a temperature-based fan speed control using Arduino. Most of the components should be easily available in your local hardware shopĪrduino Fan Speed Control using Temperature Sesnor We have also built a project to perform Automatic AC temperature control, you can also check that out if you are intrested. Let's discuss more on this is done so that you can build one on your own. To do this we will be using an Arduino UNO Board, LCD, DHT11 sensor Module, and DC fan that is controlled by using PWM. With this circuit, we will be able to adjust the fan speed in our home or office according to the room temperature and also show the temperature and fan speed changes on a 16x2 LCD display. In this arduino based project, we are going to build a temperature-controlled fan using Arduino.














Controlling a dc motor with 2n2222a transistor