进阶之路(中级篇) | 您所在的位置:网站首页 › 简易晾衣架 › 进阶之路(中级篇) |
一. 设备及要求 目的:制作一个可以自动根据事实的天气的状况进行对衣架上的衣服进行晾晒。 基础装置:可伸缩的晾衣架。 开发环境:Arduino1. 8.1 主控板:Arduino UNO 动力装置:二相四线步进电机、电机控制板 供电设备:5V/500mA电源、12V/2A电机供电电源 传感器:雨滴传感器、接触传感器 其它:双面胶若干(固定传接触感器)
二. 布线: 三.代码: 1 // I/O引脚定义 2 #define PUL 2 //电机时钟 3 #define L_ENA 3 //A电机使能 4 #define L_DIR 4 //A电机转向 5 #define L_key 5 //A电机复位按键(0) 6 #define R_ENA 6 //B电机使能 7 #define R_DIR 7 //B电机转向 8 #define R_key 8 //B电机复位按键(1) 9 #define Rain A0 //雨水 10 11 //宏定义 12 bool Clock_status = 0; 13 14 void set_init_pinMode(){ 15 pinMode(PUL,OUTPUT); //时钟 16 pinMode(L_ENA,OUTPUT); //L 17 pinMode(L_DIR,OUTPUT); 18 pinMode(L_key,INPUT); 19 pinMode(R_ENA,OUTPUT); //R 20 pinMode(R_DIR,OUTPUT); 21 pinMode(R_key,INPUT); 22 pinMode(Rain,INPUT); //雨水 23 } 24 /*************************************/ 25 //时钟函数 26 void Clock_function(void){ 27 delayMicroseconds(10000 |
CopyRight 2018-2019 实验室设备网 版权所有 |