本帖最后由 冰峰侠 于 2019-4-30 23:53 编辑
打坏了一个费时5小时
3D打印的花盆,耗时22小时
3d打印花盆
下载:Kittenblock软件,安装、运行;
设计建模
打印外壳
外壳3d打印
外可组装结果
经过实际比对其它的土壤传感器,发现这个传感器灵敏度一般,临时选择了结构更小更高灵敏度的土壤传感器,占地只有这个传感器的4分之一
控制中心外壳
整体效果
侧面
关灯瞬间
光线传感器自动启动灯光补光
补光中
开灯状态手动遮挡光纤传感器,自动启动补光效果
夜间自动补光拍照
光线符合状态下,补光灯不亮
手机app控制端
可以手动控制,也可以自动控制下面是模块化编程
[mw_shl_code=arduino,true]#include <SoftwareSerial.h>
#include <aduino_ColorLED.h>
#include <aduino_Tem_Hum.h>
Tem_D1 termo;
String currentInfo="";
#define my_Serial Serial1
ColorLED strip = ColorLED(1, 6);
String wendu;
String shidu;
String guangxian;
String automode;
String bluecs;
void setup()
{
my_Serial.begin(9600);
strip.begin();
wendu = "24.13°";
shidu = "400";
guangxian = "400";
automode = "auto";
bluecs = "";
pinMode(A2,INPUT);
termo.begin();
pinMode(A0,INPUT);
Serial.begin(9600);
pinMode(4, OUTPUT);
}
void loop()
{
shidu = analogRead(A2);
wendu = termo.getTemperature();
guangxian = analogRead(A0);
delay(100);
Serial.println(String(wendu) + String(String("|") + String(String(shidu) + String(String("|") + String(guangxian)))));
if (my_Serial.available() > 0) {
currentInfo = my_Serial.readStringUntil('\n');
if (currentInfo == "noauto") {
automode = "noauto";
} else {
bluecs = currentInfo;
}
if (currentInfo == "auto") {
automode = "auto";
} else {
bluecs = currentInfo;
}
}
my_Serial.println(String(wendu) + String(String("|") + String(String(shidu) + String(String("|") + String(guangxian)))));
if (automode == "auto") {
if (String(guangxian).toInt() < 405) {
Serial.println("开灯");
strip.setPixelColor(1-1, 204,51,204);
strip.show();
} else {
Serial.println("关灯");
strip.setPixelColor(1-1, 0,0,0);
strip.show();
}
if (String(shidu).toInt() < 405) {
Serial.println("浇水打开");
digitalWrite(4,HIGH);
delay(1000);
Serial.println("浇水关闭");
digitalWrite(4,LOW);
}
} else {
if (bluecs == "open") {
Serial.println("开灯");
strip.setPixelColor(1-1, 255,0,0);
strip.show();
} else if (bluecs == "close") {
Serial.println("关灯");
strip.setPixelColor(1-1, 0,0,0);
strip.show();
}
if (bluecs == "water") {
Serial.println("浇水打开");
digitalWrite(4,HIGH);
delay(1000);
digitalWrite(4,LOW);
bluecs = "";
} else if (bluecs == "closewater") {
Serial.println("浇水关闭");
digitalWrite(4,LOW);
}
}
Serial.println(automode);
}[/mw_shl_code]
下面是手机app的模块化编程代码
|