efinf:blc2016:bu1:projekt1:projekt

This is an old revision of the document!


Branchium Aquae

Bau eines Feuchtigkeitsmessinstruments, welches bei einer gewissen Feuchtigkeit automatisch die Pflanze bewässert

Bau eines Feuchtigkeitsmessinstruments, welches bei einer gewissen Feuchtigkeit automatisch die Pflanze bewässert

Arduino
MicroServo SG90
4-digit 7-segment display
Soil Moisture Sensor YL-69
#include <Servo.h>
#include <TM1637Display.h>
int servoPin = 9;
const int CLK = 12; //Set the CLK pin connection to the display
const int DIO = 11; //Set the DIO pin connection to the display
Servo servo; 
int rainPin = A0;
int greenLED = 6;
int redLED = 7;
int yellowLED = 4;
// you can adjust the threshold value
int thresholdValue = 700;
int servoAngle = 0;   // servo position in degrees
int NumStep = 0;  //Variable to interate
TM1637Display display(CLK, DIO);  //set up the 4-Digit Display.
void setup(){
pinMode(rainPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
Serial.begin(9600);
servo.attach(servoPin);
display.setBrightness(0x0a);  //set the diplay to maximum brightness
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(rainPin);
Serial.print(sensorValue);
if(sensorValue > thresholdValue-100 && sensorValue < thresholdValue){
  Serial.println(" - Bald Wasser geh");
  digitalWrite(redLED, LOW);
  digitalWrite(greenLED, LOW);
  digitalWrite(yellowLED, HIGH);
  display.showNumberDec(sensorValue); //Display the Variable value;
  delay(500);
}
else if(sensorValue < thresholdValue){
  Serial.println(" - Gnueg nass");
  digitalWrite(redLED, LOW);
  digitalWrite(greenLED, HIGH);
  digitalWrite(yellowLED, LOW);
  display.showNumberDec(sensorValue); //Display the Variable value;
  delay(500);
  servo.detach();
  
  
}
 else if (sensorValue > thresholdValue){
  servo.attach(servoPin);
  Serial.println(" - Gib Wasser!");
  digitalWrite(redLED, HIGH);
  digitalWrite(greenLED, LOW);
  digitalWrite(yellowLED, LOW);
  display.showNumberDec(sensorValue); //Display the Variable value;
  delay(500);
  servo.write(1);
  delay(2000);
  for (int i=1; i<136; i++) {
    servo.write(i);
    delay(10); 
  }
  servo.write(135);
 
}

delay(500);
}

Rest (Achtung: Sevobox ersetzen):

Dieses Projekt kann man in 4 Tagen beenden.

  • efinf/blc2016/bu1/projekt1/projekt.1489672750.txt.gz
  • Last modified: 2017/03/16 14:59
  • by raphael_waespi