This is an old revision of the document!


Sperietoare Animale Rapitoare Pentru Ferme

Student: Alexandru Olteanu, 332CA

Introducere

Proiectul reprezinta un sistem ce poate fi folosit in recoletele de rosii, castraveti, etc pentru fermele din Romania. Acesta poate aduce un plus de siguranta deoarece intercepteaza distantele pana la animalele / pasarile care dauneaza recolta.

Descriere Generala

Sistemul presupune un senzor ultrasonic de distanta prin care un obiect aflat in fata acestuia este interceptat, calculandu-se distanta pana la el. Distanta este in permanenta afisata pe un LCD, iar daca distanta scade sub o anumita valoare minima, un servomotor porneste miscarea unei elice care are rolul de a speria “animalul rapitor”.

Schema Bloc

Hardware Design

  1. Fire de legatura
  2. Arduino UNO
  3. Senzor Ultrasonic
  4. Display LCD
  5. Rezistenta 220 Ohmi
  6. Servomotor
  7. Elice

Cod Software

#include <Adafruit_LiquidCrystal.h>

#include <LiquidCrystal.h> #include<Servo.h>

#define echo 4 #define trigger 5 Adafruit_LiquidCrystal lcd(0);

const int inf = 2e9; int pos = 0; double duration, distance; double before_distance = inf; Servo servomotor;

void setup() {

servomotor.attach(7);
DDRD |= (1 << trigger);
DDRD &= ~(1 << echo);
Serial.begin(9600);
lcd.begin(16, 2);

}

void updateDistance() {

PORTD |= (1 << trigger);
delayMicroseconds(5);
PORTD &= ~(1 << trigger);
duration = pulseIn(echo, HIGH);
distance = (float)duration * (0.0345) / 2;
if (fabs(distance - before_distance) < 3e-1) {
  distance = before_distance;
}
else {
  before_distance = distance;
}

}

void loop() {

updateDistance();

lcd.setCursor(0,0);
lcd.print("Distance is: ");
lcd.setCursor(0, 1); 
lcd.print(distance); 
lcd.print(" cm");
if (distance <= 100) {
  for (pos = 0; pos <= 180; pos += 1) {
    // tell servo to go to position in variable 'pos'
    servomotor.write(pos);
    updateDistance();
    if (distance > 100) {
     	break; 
    }
    delay(15);
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    servomotor.write(pos);
    updateDistance();
    if (distance > 100) {
     	break; 
    }
    delay(15);
  }
}

}

pm/prj2023/vstoica/sperietoare_animale_ferma_-_alexandru_olteanu_332ca.1685204887.txt.gz · Last modified: 2023/05/27 19:28 by alexandru.olteanu01
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0