1349| 1
|
[讨论交流] 智慧小农场(带灯带版) |
/*! * MindPlus * mpython * */ #include <MPython.h> #include <IOBOX_Motor.h> #include <DFRobot_NeoPixel.h> // 函数声明 void DF_PuGuang(); void DF_ZiDongJiaoShui(); void DF_HuiZhuan(); // 创建对象 DFRobot_NeoPixel neoPixel_P0; IOBOX_Motor motor_ib; // 主程序开始 void setup() { mPython.begin(); neoPixel_P0.begin(P0, 5, 255); display.setCursor(34, 22); display.print("智慧小农场"); delay(3000); display.fillScreen(0); } void loop() { display.setCursor(34, 22); display.print(" "); display.setCursor(34, 22); display.print((String("水分:") + String((analogRead(P0))))); delay(1000); display.fillScreen(0); display.setCursor(34, 22); display.print((String("水分:") + String((analogRead(P0))))); DF_ZiDongJiaoShui(); } // 自定义函数 void DF_PuGuang() { if (((light.read())<50)) { neoPixel_P0.setRangeColor(0, 7, 0xFFFFFF); } else { neoPixel_P0.clear(); } } void DF_ZiDongJiaoShui() { if (((analogRead(P0))<200)) { motor_ib.motorRun(motor_ib.M1, motor_ib.CW, 200); } else { DF_HuiZhuan(); } } void DF_HuiZhuan() { motor_ib.motorStop(motor_ib.M1); } |
166.8 KB, 下载次数: 3799
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed