This shows you the differences between two versions of the page.
| pm:prj2021:alazar:smokedetector [2021/06/02 21:57] florina.drastaru | pm:prj2021:alazar:smokedetector [2021/06/03 18:18] (current) florina.drastaru | ||
|---|---|---|---|
| Line 37: | Line 37: | ||
| * Leduri | * Leduri | ||
| * Buzzer | * Buzzer | ||
| - | * | + | |
| **Schema tinkercad**: | **Schema tinkercad**: | ||
| Line 70: | Line 70: | ||
| * ledul rosu -> este aprins atunci cand se detecteaza o cantitate mai mare de fum(senzorul citeste o valoare mai mare decat 380) | * ledul rosu -> este aprins atunci cand se detecteaza o cantitate mai mare de fum(senzorul citeste o valoare mai mare decat 380) | ||
| * buzzerul porneste concomitent cu ledul rosu, atunci cand se da semnalul de alerta | * buzzerul porneste concomitent cu ledul rosu, atunci cand se da semnalul de alerta | ||
| + | |||
| + | <spoiler Cod Arduino> | ||
| + | <code> | ||
| + | #include <LiquidCrystal.h> | ||
| + | LiquidCrystal lcd(7, 6, 5, 4, 3, 2); | ||
| + | |||
| + | int redLed = 10; | ||
| + | int greenLed = 11; | ||
| + | int orangeLed = 12; | ||
| + | int buzzer = 8; | ||
| + | int readSmoke = A0; | ||
| + | int maxLimit = 380; | ||
| + | int minLimit = 300; | ||
| + | |||
| + | void setup() { | ||
| + | pinMode(redLed, OUTPUT); | ||
| + | pinMode(greenLed, OUTPUT); | ||
| + | pinMode(buzzer, OUTPUT); | ||
| + | pinMode(orangeLed, OUTPUT); | ||
| + | pinMode(readSmoke, INPUT); | ||
| + | Serial.begin(9600); | ||
| + | lcd.begin(16,2); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | int analogSensor = analogRead(readSmoke); | ||
| + | |||
| + | Serial.print("Pin A0: "); | ||
| + | Serial.println(analogSensor); | ||
| + | lcd.print("Smoke Level:"); | ||
| + | lcd.print(analogSensor-50); | ||
| + | if (analogSensor-50 > maxLimit) | ||
| + | { | ||
| + | digitalWrite(redLed, HIGH); | ||
| + | lcd.setCursor(0, 2); | ||
| + | lcd.print("Alert....!!!"); | ||
| + | digitalWrite(greenLed, LOW); | ||
| + | digitalWrite(orangeLed, LOW); | ||
| + | tone(buzzer, 1000, 200); | ||
| + | } else if (analogSensor - 50 > minLimit) { | ||
| + | digitalWrite(redLed, LOW); | ||
| + | digitalWrite(orangeLed, HIGH); | ||
| + | digitalWrite(greenLed, LOW); | ||
| + | lcd.setCursor(0, 2); | ||
| + | lcd.print("Be carreful....!!!"); | ||
| + | noTone(buzzer); | ||
| + | } | ||
| + |  | ||
| + | else | ||
| + | { | ||
| + | digitalWrite(redLed, LOW); | ||
| + | digitalWrite(greenLed, HIGH); | ||
| + | digitalWrite(orangeLed, LOW); | ||
| + | lcd.setCursor(0, 2); | ||
| + | lcd.print(".....Normal....."); | ||
| + | noTone(buzzer); | ||
| + | } | ||
| + | delay(500); | ||
| + | lcd.clear(); | ||
| + | } | ||
| + | </code> | ||
| + | </spoiler> | ||
| + | |||
| === Rezultate obtinute === | === Rezultate obtinute === | ||
| Line 95: | Line 158: | ||
| - | === Download === | ||
| - | {{smoke_detector.pdf}} | ||
| === Jurnal === | === Jurnal === | ||
| Line 106: | Line 167: | ||
| === Bibliografie/Resurse === | === Bibliografie/Resurse === | ||
| + | * https://lastminuteengineers.com/i2c-lcd-arduino-tutorial/ | ||
| + | * https://lastminuteengineers.com/mq2-gas-senser-arduino-tutorial/ | ||
| + | * {{smoke_detector2.pdf}} | ||