This shows you the differences between two versions of the page.
pm:prj2022:cstan:17 [2022/05/27 23:59] Mihaela.Manciu [Hardware Design] |
pm:prj2022:cstan:17 [2022/06/02 08:40] (current) Mihaela.Manciu [Software Design] |
||
---|---|---|---|
Line 40: | Line 40: | ||
</note> | </note> | ||
- | }===== Software Design ===== | + | |
+ | ===== Software Design ===== | ||
<note tip> | <note tip> | ||
Code Description: | Code Description: | ||
+ | - libraries for servo motor and sensors are included | ||
+ | - components' pins are declared | ||
+ | - setup() function: data pin of the servo motor, INPUT pins(ECHO) and OUTPUT pins(TRIGGER) are configured | ||
+ | - loop() function: firstly it verifies if there is any fire inside the trash can(if yes, sends a message), then checks if the trash can is full(if yes, sends a message) and then the servo motor opens the lid if the distance between hand and lid is less than 10 cm. | ||
- | * libraries: DHT sensor library, Servo | ||
- | </note> | + | * Libraries: DHT sensor library, Servo |
- | #include <Servo.h> | + | * Source Code: {{:pm:prj2022:cstan:code_trash_can.txt|}} |
- | #iclude "DHT.h" | + | |
- | #define DHTPIN 13 | + | |
- | #define DHTTYPE DHT11 | + | |
- | DHT dht(DHTPIN, DHTTYPE); | + | |
- | Servo servoMain1; // Define our Servo | + | |
- | Servo servoMain2; | + | |
- | int trigpin1 = 11; | + | |
- | int echopin1 = 10; | + | |
- | int trigpin2= 7; | + | |
- | int echopin2 = 6; | + | |
- | int distance1; | + | |
- | int distance2; | + | |
- | float duration; | + | |
- | + | ||
- | float cm; | + | |
- | + | ||
- | void setup(){ | + | |
- | + | ||
- | servoMain.attach(9); // servo on digital pin 10 | + | |
- | + | ||
- | pinMode(trigpin, OUTPUT); | + | |
- | + | ||
- | pinMode(echopin, INPUT); | + | |
- | + | ||
- | } | + | |
- | + | ||
- | void loop(){ | + | |
- | DHT.read11(dht_apin); | + | |
- | if(DHT.temperature>48) | + | |
- | Serial.print("Fire in the trash can!"); | + | |
- | + | ||
- | + | ||
- | digitalWrite(trigpin1, LOW); | + | |
- | delay(2); | + | |
- | digitalWrite(trigpin1, HIGH); | + | |
- | delayMicroseconds(10); | + | |
- | digitalWrite(trigpin1, LOW); | + | |
- | duration = pulseIn(echopin1, HIGH); | + | |
- | + | ||
- | cm = (duration/58.82); | + | |
- | + | ||
- | distance = cm; | + | |
- | + | ||
- | if(distance1<30){ | + | |
- | + | ||
- | servoMain1.write(90); | + | |
- | + | ||
- | delay(2000); | + | |
- | } | + | |
- | if(distance2<5) | + | |
- | Serial.print("The trash can is full!"); | + | |
- | + | ||
- | + | ||
- | } | + | |
- | + | ||
- | + | ||
- | + | ||
- | Firstly, the program verifies if there is fire in the trash can, then if the trash can is full. The loop makes the lid to open if the distance between the human and trash can is less than 30 cm. | + | |
---- | ---- | ||
+ | **Demo:** https://youtube.com/shorts/nSU-zeMt16w | ||
- | {{:pm:prj2022:cstan:whatsapp_image_2022-05-27_at_11.53.52_pm.jpeg?200|}} | + | {{:pm:prj2022:cstan:pic1_trash_can.jpeg?200|}} {{:pm:prj2022:cstan:pic2_trash_can.jpeg?200|}} |
+ | </note> | ||
===== Bibliography/Resources ===== | ===== Bibliography/Resources ===== | ||
Line 117: | Line 65: | ||
<note> | <note> | ||
---Hardware Resources--- | ---Hardware Resources--- | ||
+ | Arduino Data Sheet: https://www.arduino.cc/en/uploads/Tutorial/595datasheet.pdf | ||
+ | |||
+ | Servo Motor Data Sheet: http://www.ee.ic.ac.uk/pcheung/teaching/DE1_EE/stores/sg90_datasheet.pdf | ||
+ | |||
+ | DHT11 Humidity & Temperature Sensor Data Sheet: https://www.mouser.com/datasheet/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf | ||
</note> | </note> |