一.    设备及要求

目的:制作一个可以自动根据事实的天气的状况进行对衣架上的衣服进行晾晒。

基础装置:可伸缩的晾衣架。

开发环境:Arduino1. 8.1

主控板:Arduino UNO

动力装置:二相四线步进电机、电机控制板

供电设备:5V/500mA电源、12V/2A电机供电电源

传感器:雨滴传感器、接触传感器

其它:双面胶若干(固定传接触感器)

二.    布线:

三.代码:

 // I/O引脚定义
#define PUL 2 //电机时钟
#define L_ENA 3 //A电机使能
#define L_DIR 4 //A电机转向
#define L_key 5 //A电机复位按键(0)
#define R_ENA 6 //B电机使能
#define R_DIR 7 //B电机转向
#define R_key 8 //B电机复位按键(1)
#define Rain A0 //雨水 //宏定义
bool Clock_status = ; void set_init_pinMode(){
pinMode(PUL,OUTPUT); //时钟
pinMode(L_ENA,OUTPUT); //L
pinMode(L_DIR,OUTPUT);
pinMode(L_key,INPUT);
pinMode(R_ENA,OUTPUT); //R
pinMode(R_DIR,OUTPUT);
pinMode(R_key,INPUT);
pinMode(Rain,INPUT); //雨水
}
/*************************************/
//时钟函数
void Clock_function(void){
delayMicroseconds(); //时钟
digitalWrite(PUL,Clock_status);
Clock_status = !Clock_status;
}
/***********************************/
//电机使能关闭
void Close_motor(void){
digitalWrite(L_ENA,);
digitalWrite(R_ENA,);
}
//电机使能开启
void start_motor(void){
digitalWrite(L_ENA,);
digitalWrite(R_ENA,);
}
/**********************************/
//拉回方向
void Pull_direction(){
digitalWrite(L_DIR,);
digitalWrite(R_DIR,);
}
//推出方向
void Push_direction(){
digitalWrite(L_DIR,);
digitalWrite(R_DIR,);
}
/********************************/
//拉回电机
void Pull_motor(){
start_motor(); //开启电机
Pull_direction(); //拉回电机凤方向设置
}
//推出电机
void Push_motor(){
start_motor(); //开启电机
Push_direction(); //拉回电机凤方向设置
}
//无检验停止
void No_test_stop_motor(){
Close_motor(); //关闭使能
}
//检验停止
void test_stop_motor(int key1,int key2){
if(key1)digitalWrite(L_ENA,);
else digitalWrite(L_ENA,);
if(key2)digitalWrite(R_ENA,);
else digitalWrite(L_ENA,);
}
/********************************/
void printf_all(int mode,unsigned int step1){
Serial.print("mode =");
Serial.print(mode);
Serial.print(" ");
Serial.print("PUL =");
Serial.print(digitalRead(PUL));
Serial.print(" ");
Serial.print("L_DIR =");
Serial.print(digitalRead(L_DIR));
Serial.print(" ");
Serial.print("L_ENA =");
Serial.print(digitalRead(L_ENA));
Serial.print(" ");
Serial.print("L_key =");
Serial.print(digitalRead(L_key));
Serial.print(" ");
Serial.print("R_DIR =");
Serial.print(digitalRead(R_DIR));
Serial.print(" ");
Serial.print("R_ENA =");
Serial.print(digitalRead(R_ENA));
Serial.print(" ");
Serial.print("R_key =");
Serial.print(digitalRead(R_key));
Serial.print(" ");
Serial.print("Rain =");
Serial.print(analogRead(Rain));
Serial.print(" ");
Serial.print("step1 =");
Serial.println(step1);
}
//初始化
void setup(){
set_init_pinMode();
Serial.begin();
Serial.println("DHTxx test!");
}
void loop(){
int mode = ; //模式
int a,b;
unsigned int step1 = ;
while(){
switch(mode){
case :{ //拉回电机
Pull_motor();
mode = ;
}break;
case :{ //检测状态
a = digitalRead(L_key);
b = digitalRead(R_key);
digitalWrite(L_ENA,a);
digitalWrite(R_ENA,b-);
step1--;
if((==a)&&(==b)&&(analogRead(Rain) > )){
mode = ;
step1 = ;
Push_motor();
}
}break;
case :{ //雨板检测
if(analogRead(Rain) < )mode = ;
else if( < step1++){
Close_motor();
step1 = ;
}
}break;
}
//printf_all(mode,step1);
Clock_function();
}
}

四.    缺陷与不足:

  1. 雨板模拟量干扰没有处理
  2. 按键干扰没有处理
  3. 没有电源检测
  4. 没有光线检测
  5. 没有衣物干燥度检测
  6. 没有备用电源
  7. 没有电源停电检

进阶之路(中级篇) - 018 基于arduino的简易版智能衣架的更多相关文章

  1. docker进阶之路-基础篇 | 二:portainer安装与基本使用

    转载请注明作者及出处: 作者:银河架构师 原文链接:https://www.cnblogs.com/luas/p/12061755.html ​简介 Portainer 是轻量级,跨平台,开源的管理D ...

  2. docker进阶之路-基础篇 | 一:环境搭建

    转载请注明作者及出处: 作者:银河架构师 原文链接:https://www.cnblogs.com/luas/p/12061747.html 一.准备工作 查看内核 Docker 要求 CentOS ...

  3. Netty(四)基于Netty 的简易版RPC

    3.1 RPC 概述 下面的这张图,大概很多小伙伴都见到过,这是 Dubbo 官网中的一张图描述了项目架构的演进过程 它描述了每一种架构需要的具体配置和组织形态.当网站流量很小时,只需一个应用,将所有 ...

  4. 基于djiango实现简易版的图书管理系统

    介绍: 本程序仅仅实现图书数据的增删查 树形结构如下   全部代码如下: url: from django.urls import path from front import views as fr ...

  5. 运维工程师打怪升级进阶之路 V2.0

    在此之前,发布过两个版本: 运维工程师打怪升级之路 V1.0 版本发布 运维工程师打怪升级必经之路 V1.0.1 很多读者伙伴们反应总结的很系统.很全面,无论是0基础初学者,还是有基础的入门者,或者是 ...

  6. 进阶之路(基础篇) - 021 arduino基础知识

    什么是arduino(翻译自arduino官方介绍)Arduino 是一款便捷灵活.方便上手的开源电子原型平台,包含硬件(各种型号的arduino板)和软件(arduino IDE).她适用于艺术家. ...

  7. Java 进阶 hello world! - 中级程序员之路

    Java 进阶 hello world! - 中级程序员之路 Java是一种跨平台的语言,号称:"一次编写,到处运行",在世界编程语言排行榜中稳居第二名(TIOBE index). ...

  8. Scala进阶之路-并发编程模型Akka入门篇

    Scala进阶之路-并发编程模型Akka入门篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Akka Actor介绍 1>.Akka介绍 写并发程序很难.程序员不得不处 ...

  9. Scala进阶之路-Scala函数篇详解

    Scala进阶之路-Scala函数篇详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.传值调用和传名调用 /* @author :yinzhengjie Blog:http: ...

随机推荐

  1. "Value does not fall within the expected range" with managed metadata fields

      From: http://geekswithblogs.net/claraoscura/archive/2011/01/21/143569.aspx The problem: I have an ...

  2. 解决webstom failed to change read-only files

    我百思不得其解的是,为何我的文件不让我更改,变成了只读模式,后来我仔细回忆了一下,原来是因为我使用了root权限,来安装thinkjs之后,webstom没有root权限,所以我使用root,在终端敲 ...

  3. java多线程分块上传并支持断点续传最新修正完整版本[转]

    package com.test; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.Fi ...

  4. springboot项目在Eclipse/Myeclipse中Debug启动跳转至断点(exitCurrentThread)

    Spring Boot项目使用了spring-boot-devtools工具且在Eclipse中Debug调试会自动跳转到这个方法: public static void exitCurrentThr ...

  5. python网络爬虫 - 如何伪装逃过反爬虫程序

    有的时候,我们本来写得好好的爬虫代码,之前还运行得Ok, 一下子突然报错了. 报错信息如下: Http 800 Internal internet error 这是因为你的对象网站设置了反爬虫程序,如 ...

  6. 树莓派系统(Debain)中设置固定静态IP地址

    一.方法: 1.使用ssh登陆,使用以下命令设置静态ip. sudo nano /etc/dhcpcd.conf2.在dhcpcd.conf后添加以下内容(网上的方法): interface eth0 ...

  7. 使用Flask+MongoDB实现基于REST的接口简单操作

    目录 前言 1 准备工作 2 具体实现 前言 最近在捣鼓如何使用阿里云服务器搭建一个简单的基于Flask框架的后端接口,刚开始为了图方便,就直接买了一个Windows Server 2008系统服务器 ...

  8. 批量 ping 测试脚本(IP 扫描)

    是否会使用 vpn 工作,已经成为魔法师和麻瓜之间最重要的区分.使用 vpn 工作,也产生了其它一些奇奇怪怪的问题,比如,选择 vpn 服务器. 你要测试哪个 vpn 离你最近. 所以,就有了下面的脚 ...

  9. SCD Type2 in ODI

    缓慢变化维(Slowly changing Dimensions)指的是维表中的维度字段值会随着时间或业务调整,而在后续的分析中,历史数据仍然要使用旧的维度值,新的数据会使用当前维度值.在数据仓库建设 ...

  10. SpringCloud stream连接RabbitMQ收发信息

    百度上查的大部分都是一些很简单的单消费者或者单生产者的例子,并且多是同一个服务器的配置,本文的例子为多服务器配置下的消费生产和消费者配置. 参考资料:https://docs.spring.io/sp ...