This shows you the differences between two versions of the page.
|
pm:prj2022:apredescu:soapdispenser [2022/06/01 00:30] 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 21: | Line 24: | ||
| <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 | ||
| * 330 Ohm Resistor - 1 | * 330 Ohm Resistor - 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) | + | |
| - | * diagrame de semnal | + | |
| - | * rezultatele simulării | + | |
| </note> | </note> | ||
| Line 37: | Line 38: | ||
| <note tip> | <note tip> | ||
| * Arduino IDE | * Arduino IDE | ||
| + | * Additional Library: Servo.h | ||
| + | <code cvp> | ||
| #include <Servo.h> | #include <Servo.h> | ||
| - | Servo servo; | + | Servo servo1; |
| + | Servo servo2; | ||
| int trigPin = 5; | int trigPin = 5; | ||
| int echoPin = 6; | int echoPin = 6; | ||
| - | int servoPin = 9; | + | int servo1Pin = 9; |
| + | int servo2Pin = 8; | ||
| int led= 10; | int led= 10; | ||
| long duration, dist, average; | long duration, dist, average; | ||
| Line 56: | Line 61: | ||
| int val = 0; | int val = 0; | ||
| - | // Declare pins to which LEDs are connected | ||
| int redLED = 2; | int redLED = 2; | ||
| - | |||
| - | |||
| - | |||
| int readSensor() { | int readSensor() { | ||
| Line 69: | Line 70: | ||
| return val; | return val; | ||
| } | } | ||
| - | |||
| - | |||
| void setup() { | void setup() { | ||
| Serial.begin(9600); | Serial.begin(9600); | ||
| - | servo.attach(servoPin); | + | servo1.attach(servo1Pin); |
| + | servo2.attach(servo2Pin); | ||
| pinMode(trigPin, OUTPUT); | pinMode(trigPin, OUTPUT); | ||
| pinMode(echoPin, INPUT); | pinMode(echoPin, INPUT); | ||
| - | servo.write(0); //close cap on power on | + | servo1.write(0); //close cap on power on |
| + | servo2.write(0); | ||
| delay(100); | delay(100); | ||
| - | |||
| - | |||
| - | |||
| Serial.begin(9600); | Serial.begin(9600); | ||
| Line 87: | Line 85: | ||
| digitalWrite(sensorPower, LOW); | digitalWrite(sensorPower, LOW); | ||
| | | ||
| - | // Set LED pins as an OUTPUT | + | // Set LED pin as an OUTPUT |
| pinMode(redLED, OUTPUT); | pinMode(redLED, OUTPUT); | ||
| - | // Initially turn off all LEDs | + | // Initially turn off the LED |
| digitalWrite(redLED, LOW); | digitalWrite(redLED, LOW); | ||
| } | } | ||
| Line 105: | Line 103: | ||
| dist = (duration/2) / 29.1; //obtain distance | dist = (duration/2) / 29.1; //obtain distance | ||
| } | } | ||
| - | |||
| void loop() { | void loop() { | ||
| for (int i=0;i<=2;i++) { //average distance | for (int i=0;i<=2;i++) { //average distance | ||
| Line 115: | Line 112: | ||
| if ( dist<15 ) { | if ( dist<15 ) { | ||
| - | //Change distance as per your need | + | |
| delay(1); | delay(1); | ||
| - | servo.write(0); | + | servo1.write(0); |
| + | servo2.write(0); | ||
| delay(3000); | delay(3000); | ||
| - | servo.write(150); | + | servo1.write(150); |
| + | servo2.write(150); | ||
| delay(1000); | delay(1000); | ||
| Line 140: | Line 139: | ||
| } | } | ||
| - | + | </code> | |
| - | + | ||
| </note> | </note> | ||
| Line 148: | 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 ===== | ||