This shows you the differences between two versions of the page.
|
pm:prj2022:apredescu:soapdispenser [2022/05/30 14:05] petru.musat [Hardware Design] |
pm:prj2022:apredescu:soapdispenser [2022/06/02 12:10] (current) petru.musat [Concluzii] |
||
|---|---|---|---|
| Line 9: | Line 9: | ||
| * Elimina riscul de a lua bacterii si anunta cand nu mai este sapun in sticla print-un LED | * Elimina riscul de a lua bacterii si anunta cand nu mai este sapun in sticla print-un LED | ||
| </note> | </note> | ||
| - | ===== Descriere generală ===== | + | |
| + | |||
| + | ===== Descriere Generala ===== | ||
| <note tip> | <note tip> | ||
| - | O schemă bloc cu toate modulele proiectului vostru, atât software cât şi hardware însoţită de o descriere a acestora precum şi a modului în care interacţionează. | + | Schema bloc: |
| - | Exemplu de schemă bloc: http://www.robs-projects.com/mp3proj/newplayer.html | + | {{:pm:prj2022:apredescu:proiect_ma.png?600|}} |
| </note> | </note> | ||
| Line 20: | Line 23: | ||
| <note tip> | <note tip> | ||
| - | - Arduino Mega - 1 | + | * Arduino Mega - 1 |
| - | - Servomotor SG90 - 1 | + | * Servomotor SG90 - 2 |
| - | - Senzor ultrasonic de proximitate HC-SR04 - 1 | + | * Senzor ultrasonic de proximitate HC-SR04 - 1 |
| - | - Senzor nivel apa - 1 | + | * Senzor nivel apa - 1 |
| - | - L.E.D. - 1 | + | * L.E.D. - 1 |
| - | * scheme electrice (se pot lua şi de pe Internet şi din datasheet-uri, e.g. http://www.captain.at/electronic-atmega16-mmc-schematic.png) | + | * 330 Ohm Resistor - 1 |
| - | * diagrame de semnal | + | |
| - | * rezultatele simulării | + | |
| </note> | </note> | ||
| Line 34: | Line 37: | ||
| <note tip> | <note tip> | ||
| - | Descrierea codului aplicaţiei (firmware): | + | * Arduino IDE |
| - | * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) | + | * Additional Library: Servo.h |
| - | * librării şi surse 3rd-party (e.g. Procyon AVRlib) | + | |
| - | * algoritmi şi structuri pe care plănuiţi să le implementaţi | + | <code cvp> |
| - | * (etapa 3) surse şi funcţii implementate | + | #include <Servo.h> |
| + | Servo servo1; | ||
| + | Servo servo2; | ||
| + | int trigPin = 5; | ||
| + | int echoPin = 6; | ||
| + | int servo1Pin = 9; | ||
| + | int servo2Pin = 8; | ||
| + | int led= 10; | ||
| + | long duration, dist, average; | ||
| + | long aver[3]; //array for average | ||
| + | int lowerThreshold = 420; | ||
| + | int upperThreshold = 520; | ||
| + | |||
| + | // Sensor pins | ||
| + | #define sensorPower 7 | ||
| + | #define sensorPin A0 | ||
| + | |||
| + | // Value for storing water level | ||
| + | int val = 0; | ||
| + | |||
| + | int redLED = 2; | ||
| + | |||
| + | int readSensor() { | ||
| + | digitalWrite(sensorPower, HIGH); | ||
| + | delay(10); | ||
| + | val = analogRead(sensorPin); | ||
| + | digitalWrite(sensorPower, LOW); | ||
| + | return val; | ||
| + | } | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(9600); | ||
| + | servo1.attach(servo1Pin); | ||
| + | servo2.attach(servo2Pin); | ||
| + | pinMode(trigPin, OUTPUT); | ||
| + | pinMode(echoPin, INPUT); | ||
| + | servo1.write(0); //close cap on power on | ||
| + | servo2.write(0); | ||
| + | delay(100); | ||
| + | |||
| + | Serial.begin(9600); | ||
| + | pinMode(sensorPower, OUTPUT); | ||
| + | digitalWrite(sensorPower, LOW); | ||
| + | |||
| + | // Set LED pin as an OUTPUT | ||
| + | pinMode(redLED, OUTPUT); | ||
| + | |||
| + | // Initially turn off the LED | ||
| + | digitalWrite(redLED, LOW); | ||
| + | } | ||
| + | |||
| + | void measure() { | ||
| + | digitalWrite(10,HIGH); | ||
| + | digitalWrite(trigPin, LOW); | ||
| + | delayMicroseconds(5); | ||
| + | digitalWrite(trigPin, HIGH); | ||
| + | delayMicroseconds(15); | ||
| + | digitalWrite(trigPin, LOW); | ||
| + | pinMode(echoPin, INPUT); | ||
| + | duration = pulseIn(echoPin, HIGH); | ||
| + | dist = (duration/2) / 29.1; //obtain distance | ||
| + | } | ||
| + | void loop() { | ||
| + | for (int i=0;i<=2;i++) { //average distance | ||
| + | measure(); | ||
| + | aver[i]=dist; | ||
| + | delay(10); //delay between measurements | ||
| + | } | ||
| + | dist=(aver[0]+aver[1]+aver[2])/3; | ||
| + | |||
| + | if ( dist<15 ) { | ||
| + | |||
| + | delay(1); | ||
| + | servo1.write(0); | ||
| + | servo2.write(0); | ||
| + | delay(3000); | ||
| + | servo1.write(150); | ||
| + | servo2.write(150); | ||
| + | delay(1000); | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | int level = readSensor(); | ||
| + | |||
| + | if (level <= 50) { | ||
| + | Serial.println("Water Level: Low"); | ||
| + | digitalWrite(redLED, HIGH); | ||
| + | } | ||
| + | else if (level > 50) { | ||
| + | Serial.println("Water Level: High"); | ||
| + | digitalWrite(redLED, LOW); | ||
| + | |||
| + | } | ||
| + | delay(1000); | ||
| + | } | ||
| + | |||
| + | } | ||
| + | </code> | ||
| </note> | </note> | ||
| Line 44: | Line 145: | ||
| <note tip> | <note tip> | ||
| - | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | + | {{:pm:prj2022:apredescu:soap_dispenser_1.jpg?600|}} |
| + | {{:pm:prj2022:apredescu:soap_dispenser_2.jpg?600|}} | ||
| + | {{:pm:prj2022:apredescu:soap_dispenser_3.jpg?600|}} | ||
| </note> | </note> | ||
| ===== Concluzii ===== | ===== Concluzii ===== | ||
| + | 2 servo motoare SG90 nu sunt destul pentru a apasa pompa unei sticle de sapun lichid | ||
| ===== Download ===== | ===== Download ===== | ||