Windows IoT:温度控制电动机《如何制作散热风扇》
本帖最后由 newsmanager 于 2015-12-25 08:28 编辑
***附件停止解析***
想做一个温控散热风扇?很简单,动手实践吧!你还可以通过温度控制电动机此原理,用温度控制电动机转动,做一些其它有意思的事情,你可能需要C/C++的基本知识。
原理:温度传感器感受到外界温度变化,如温度上升,传感器将数据反馈到树莓派2并实现继电器的电路控制,使得小风扇转动发生不同幅度的变化。
你需要以下这些东西:
[list]
[*]Raspberry Pi 1 Model B+(本教程使用的是Raspberry Pi 2 B型)
[*]5V继电器220V x1
[*]DHT11 温度&湿度传感器×1
[*]Fractal Design Silent Series R3 80mm(本文使用的是小风扇)
[*]12V DC电源适配器
[*]面包板 x1
[*]杜邦线若干
[/list]
按照以下电路参照图连接:
***附件停止解析***
(Raspberry pi 2通用I/O接口)
***附件停止解析***
代码(读取传感器的值):
[mw_shl_code=c,true]#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define MAXTIMINGS 85
#define DHTPIN 4
int dht11_dat[5] = { 0, 0, 0, 0, 0 };
float read_dht11_dat()
{
uint8_t laststate = HIGH;
uint8_t counter = 0;
uint8_t j = 0, i;
float result = -1;
dht11_dat[0] = dht11_dat[1] = dht11_dat[2] = dht11_dat[3] = dht11_dat[4] = 0;
/* pull pin down for 18 milliseconds */
pinMode( DHTPIN, OUTPUT );
digitalWrite( DHTPIN, LOW );
delay( 18 );
/* then pull it up for 40 microseconds */
digitalWrite( DHTPIN, HIGH );
delayMicroseconds( 40 );
/* prepare to read the pin */
pinMode( DHTPIN, INPUT );
/* detect change and read data */
for ( i = 0; i < MAXTIMINGS; i++ )
{
counter = 0;
while ( digitalRead( DHTPIN ) == laststate )
{
counter++;
delayMicroseconds( 1 );
if ( counter == 255 )
{
break;
}
}
laststate = digitalRead( DHTPIN );
if ( counter == 255 )
break;
/* ignore first 3 transitions */
if ( (i >= 4) && (i % 2 == 0) )
{
/* shove each bit into the storage bytes */
dht11_dat[j / 8] <<= 1;
if ( counter > 16 )
dht11_dat[j / 8] |= 1;
j++;
}
}
/*
* check that we read 40 bits & verify checksum in the last byte.
*/
if ( (j >= 40) &&
(dht11_dat[4] == ( (dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF) ) )
{
result = (1.0 * dht11_dat[2]) + ((float)dht11_dat[3]/10.0);
}
return result;
}[/mw_shl_code]
代码(继电器控制):
[mw_shl_code=c,true]#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define RELAYPIN 2
#define TEMPMAX 30
int state = 0;
void controlRelay(float avg_t){
pinMode( RELAYPIN, OUTPUT );
if(avg_t > TEMPMAX-state){
digitalWrite( RELAYPIN, HIGH );
state = 1;
}
else{
digitalWrite( RELAYPIN, LOW );
state = 0;
}
}[/mw_shl_code]
注意:如果你想进行修改一些参数以实践其他类似项目,你需要C/C++基础。参照图和代码来源***链接停止解析***。
本文持续更新....
为防止不可控的内容风险,本站已关闭新用户注册,新贴的发表及评论;
你现在看到的内容只是互联网用户曾经发表的言论快照,仅用于老用户留存纪念,且仅与科技行业相关,全部内容不代表本站观点及立场;
本站重新开放前已针对包括用户隐私、版权保护、信息安全、国家政策在内的各种互联网法律法规要求,执行了隐患内容的自查、屏蔽和删除;
本站目前所属个人主体,未有任何盈利安排与计划,且与原WFUN.COM所属公司不存在任何关联关系;
如果本帖内容或者相关资源侵犯到您的合法权益,或者您认为存在问题,那么请您务必点此举报或投诉!
本帖最后由 dreamoyjie01 于 2015-12-25 06:43 编辑
Quote凤凰新闻WP版客户端 发表于 2015-12-25 01:51
小编沙比吧?就没有电机驱动,光靠树莓派的板子io口那点驱动,电机根本就转不起来,更别说带负载了。没文化 ...
傻仔,人家都说了用万能的继电器,又没说无级驱动,这个凤凰新闻,如果真的这么有本事就希望你先看看电路图再喷小偏。我这么能忍都看不过眼。
Quote凤凰新闻WP版客户端 发表于 2015-12-25 01:51
小编沙比吧?就没有电机驱动,光靠树莓派的板子io口那点驱动,电机根本就转不起来,更别说带负载了。没文化 ...
没文化真可怕。。。。