From de95d30b6684bc4ac716e45806ff2f59d8124f07 Mon Sep 17 00:00:00 2001 From: JasonYANG17 <39414350+JasonYANG170@users.noreply.github.com> Date: Mon, 4 Sep 2023 09:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E6=99=BA=E8=83=BD?= =?UTF-8?q?=E8=8A=82=E6=B0=B4=E8=8A=B1=E7=9B=86.ino?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加部分注释 --- 智能节水花盆/智能节水花盆.ino | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/智能节水花盆/智能节水花盆.ino b/智能节水花盆/智能节水花盆.ino index 95be764..a695bf5 100644 --- a/智能节水花盆/智能节水花盆.ino +++ b/智能节水花盆/智能节水花盆.ino @@ -1,22 +1,22 @@ /* Name: 智能节水花盆.ino Created: 2023/3/15 0:22:26 - Author: qw200 + Author: JasonYANG17 */ - +//导入配置库 #include #include #include //驱动128x64 and 128x32 的屏幕显示的库 #include //Arduino的图形库 #include #include - +//配置屏幕像素 #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) - +//定义OLED恢复引脚,无则定义为-1 #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) -Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); +Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);//配置数据 // Example testing sketch for various DHT humidity/temperature sensors // Written by ladyada, public domain @@ -32,7 +32,7 @@ int LED = 15; DHT dht(DHTPIN, DHTTYPE);//进行初始化设置 int buttonPin = 12; // 将开关连接到 -int buttonState = 0; +int buttonState = 0;//开关状态为0 void setup() { Serial.begin(9600); dht.begin();//DHT开始工作 @@ -43,15 +43,15 @@ void setup() { digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(LED, LOW); - pinMode(buttonPin, INPUT_PULLUP); // 设 + pinMode(buttonPin, INPUT_PULLUP); // 设置开关模式 //Serial.println("OLED FeatherWing test"); //串口输出信息 display.begin(SSD1306_SWITCHCAPVCC, 0x3c); //初始化OLED并设置其IIC地址为 0x3C display.clearDisplay(); //清屏 delay(200); - display.setTextSize(1.3); - display.setTextColor(SSD1306_WHITE); + display.setTextSize(1.3);//设置文本大小 + display.setTextColor(SSD1306_WHITE);//设置字体颜色 display.setCursor(0, 0); //设置光标的位置 //绘制像素点 @@ -111,7 +111,7 @@ void setup() { void loop() { // delay(2000); - buttonState = digitalRead(buttonPin); + buttonState = digitalRead(buttonPin);//读取开关通断模式,并导入至开关状态 Serial.println(analogRead(14));//湿度传感器接ESP32上的GPIO号 delay(100);