极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 18187|回复: 2

arduino+Wiscam (WiFi模块)实现智能风扇(附上下位机源代码)

[复制链接]
发表于 2017-7-6 09:20:09 | 显示全部楼层 |阅读模式
本帖最后由 fwy丶lucifer 于 2017-7-6 09:42 编辑

实验设备
(1)arduino R3开发板一块
(2)Wiscam视频开发板一块
(3)DC motor 一个
(4)IC芯片 ULN2003
(5)5V电源
(6)杜邦线若干根

基本原理
    Wiscam工作在AP或STA模式,在AP模式下,上位机连接Wiscam的热点;在STA模式下,Wiscam和上位机要连接同一个路由器。Wiscam透传串口与Arduino串口连接,上位机软件发送控制指令到Wiscam,Wiscam通过透传串口将数据传到Arduino,Arduino通过PWM控制DC motord的转速。

硬件连接
把Wiscam直接插到Arduino的母座上(端口完全对接),如图2所示arduino的PIN 9接ULN2003的PIN 1,ULN2003的PIN 16接DC motor其中一PIN,ULN2013的PIN 8接GNG(Arduino)和PIN 9接 VCC(Arduino)。组合之后单独给Wiscam供电即可(5V)。
  
测试代码
1、上位机软件(源代码)
   1)控制界面
     上位机的代码见:http://supportcn.rakwireless.com/topic/222/wiscam-intelligent-fan
       2下位机(Arduino程序
const int analogOutPin = 9; //  模拟输出引脚
int flase = 0;
int sensorValue = 0;
int outputValue = 0;
char rec[7];
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial)
  {
    ;
  }
}
void loop() {
  if (Serial.available() > 0)
  {
    flase = 1;
    for (int i = 0; i < 7; i++)
    {
      rec = Serial.read();
      Serial.print(rec ); // 打印结果到串口监视器
    }
    // 读取模拟量值Pin);
    outputValue = rec[5];
  }
  analogWrite(analogOutPin, outputValue);
  delay(200);
}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2017-9-19 17:53:56 | 显示全部楼层
学习了,谢谢分享
回复 支持 反对

使用道具 举报

发表于 2019-7-18 13:27:38 | 显示全部楼层
作者,上位机软件在哪下载啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-17 04:19 , Processed in 0.049593 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表