top of page
6edfb20301aba663ea91122c18724e5.jpg

Dog's

tail

grass

​(二)

Dog's

tail

grass

(2)

10.17

周六下午

图片1.png

The team conducted the first discussion of this assignment and determined the iterative design points of our plan and the devices that need to be updated:

1. Replace the soil moisture sensor;

2. Replace the human sensor with a more sensitive ultrasonic sensor;

3. Increase the LCD display screen and replace the previous led lights to better display the current status of the plants;

4. Increase the photoresistor, calculate the light time of the plant, and give feedback after the light reaches a certain length of time to prevent excessive light from causing damage to the plant;

And their respective tasks:

1. 张 - video

2. 董 - log

3. 桑 - website optimization

4. 李 - Arduino software optimization

5. The optimization plan for the appearance of potted plants (all)

At the same time, the missing components, namely soil moisture sensor, glue gun, and 9v battery were purchased.

10.19

​周一下午

All the purchased devices arrived, and we started to build the circuits of soil moisture sensor, LCD display, ultrasonic sensor, photoresistor and steering gear, and write corresponding programs.

图片3.png
图片2.png
图片4.png
图片5.png
图片6.png
图片7.png
图片8.png
图片9.png
图片10.png
图片11.png
图片12.png
图片13.png
图片14.png
图片15.png

Final product

After confirming that the function is running normally, we filmed this function video.

10.14

​周三下午

CODE SHARING

//构建土壤传感器的针脚
#define Moisture A0 //定义AO 引脚 为 IO-A0
#define DO 7        //定义DO 引脚 为 IO-7


#include <Servo.h>
Servo myservo;  // create servo object to control a servo
int pos = 90;    // variable to store the servo position  min:45 max:135
#define myservoAttach 9 


int TrgPin = A1;
int EcoPin = A2;
float dist;
//int flag = 0 ;


#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//构建光敏传感器
const int led=6; // variable which stores pin number
#define PIN_A 4
#define PIN_D 8

long time = 0;

void setup() {
  pinMode(Moisture, INPUT);
  pinMode(DO, INPUT);
  Serial.begin(9600);

  
  myservo.attach(myservoAttach); 

  
    
    pinMode(TrgPin, OUTPUT);
    
    pinMode(EcoPin, INPUT);


    pinMode(led, OUTPUT);  //configures pin 6 as OUTPUT
}


 
void loop() {
  delay(1000);
  
  Serial.print("Moisture=");
  Serial.print(analogRead(Moisture));
  Serial.print("|DO=");
  Serial.print(digitalRead(DO));
  Serial.print("-------");

  
  digitalWrite(TrgPin, LOW);
  delayMicroseconds(8);
  digitalWrite(TrgPin, HIGH);
  
  delayMicroseconds(10);
  digitalWrite(TrgPin, LOW);
  
  dist = pulseIn(EcoPin, HIGH) / 58.00;
  Serial.print("Distance:");
  Serial.print(dist);
  Serial.print("cm-------");

  if((int)dist <= 20){
    
  for (pos = 90; pos <= 135; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 135; pos >= 45; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 45 ; pos <= 90 ; pos += 1){
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5); 
  }


  //显示屏的输出
  if(analogRead(Moisture) >= 800){
    lcd.begin(16,2);
    lcd.print("      T^T");
  }else{
    lcd.begin(16,2);
    lcd.print("      TnT");
    }
}
else{//超声波传感器没有检测到物体时,显示屏清空
    lcd.clear();
  }

//光敏的判断逻辑
int val = analogRead(PIN_A);
Serial.print("Instense Of Light:");
Serial.print(val);
//受到光照时,累加光照时间
if(digitalRead(led) == LOW && val <= 200){
  time += 1000;
  if(time >= 5000){
      digitalWrite(led, HIGH);  //sets LEDs ON
      time = 0;
        }      
}

if(digitalRead(led) == HIGH && val >= 300){
      digitalWrite(led, LOW);  //sets LEDs ON
}
Serial.print("-------");
Serial.print("lighting time:");
Serial.println(time);
  

}

END

BEGIN

bottom of page