This shows you the differences between two versions of the page.
|
iothings:proiecte:2025sric:windowopener [2025/04/23 13:42] matei.neaga [Software] |
iothings:proiecte:2025sric:windowopener [2025/05/18 18:18] (current) matei.neaga [Window opener, based on gas detection] |
||
|---|---|---|---|
| Line 11: | Line 11: | ||
| ====== Context ====== | ====== Context ====== | ||
| + | Block diagram of the project | ||
| + | |||
| + | {{ :iothings:proiecte:2025sric:block-diagram-neaga-matei.png |}} | ||
| + | |||
| + | Flowchart of the project | ||
| + | |||
| + | {{ :iothings:proiecte:2025sric:flowchart-neaga-matei.png |}} | ||
| Line 43: | Line 50: | ||
| Servo myservo; | Servo myservo; | ||
| + | </code> | ||
| + | |||
| + | <code cpp> | ||
| + | void loop() { | ||
| + | server.handleClient(); | ||
| + | | ||
| + | | ||
| + | valoare_analogica = analogRead(ANALOG_PIN); | ||
| + | | ||
| + | | ||
| + | if (modAutomat) { | ||
| + | if (valoare_analogica >= pragActivare && !servoActiv) { | ||
| + | activeazaServo(); | ||
| + | } else if (valoare_analogica < pragActivare && servoActiv) { | ||
| + | dezactiveazaServo(); | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | delay(100); | ||
| + | } | ||
| + | |||
| + | // Funcție pentru activarea servomotorului | ||
| + | void activeazaServo() { | ||
| + | myservo.write(90); | ||
| + | servoActiv = true; | ||
| + | Serial.println("Servo activat!"); | ||
| + | } | ||
| + | |||
| + | // Funcție pentru dezactivarea servomotorului | ||
| + | void dezactiveazaServo() { | ||
| + | myservo.write(0); | ||
| + | servoActiv = false; | ||
| + | Serial.println("Servo dezactivat!"); | ||
| + | } | ||
| + | |||
| </code> | </code> | ||