├── main.cpp ├── pythoned.py ├── LICENSE └── README.md /main.cpp: -------------------------------------------------------------------------------- 1 | //این کد اصلی که به زیان سی پلاس پلاس هست مخصوص میکروکنترولر آردوینو 2 | const int sensorPin = A0; // Analog pin for reading data from the sensor 3 | const int ledPin = 13; // Digital pin for controlling the LED 4 | 5 | void setup() { 6 | pinMode(ledPin, OUTPUT); 7 | Serial.begin(9600); 8 | } 9 | 10 | void loop() { 11 | int sensorValue = analogRead(sensorPin); 12 | Serial.println(sensorValue); // Display the analog value in the Serial Monitor 13 | 14 | if (sensorValue > 100) { 15 | digitalWrite(ledPin, HIGH); // Turn off the LED if the gas value is above 100 16 | } else { 17 | digitalWrite(ledPin, LOW); // Keep the LED on otherwise 18 | } 19 | 20 | delay(1000); // Delay one second before reading the next value 21 | } 22 | //تمام توضیحات خط به خط کد در فایل readme.md 23 | -------------------------------------------------------------------------------- /pythoned.py: -------------------------------------------------------------------------------- 1 | #کد تبدیل شده به زبان پایتون 2 | import RPi.GPIO as GPIO 3 | import time 4 | 5 | sensor_pin = 17 # GPIO pin for reading data from the sensor 6 | led_pin = 27 # GPIO pin for controlling the LED 7 | 8 | GPIO.setmode(GPIO.BCM) 9 | GPIO.setup(led_pin, GPIO.OUT) 10 | 11 | try: 12 | while True: 13 | sensor_value = # Read analog value from the sensor 14 | 15 | print(sensor_value) # Print analog value to the console 16 | 17 | if sensor_value > 100: 18 | GPIO.output(led_pin, GPIO.HIGH) # Turn on the LED if the gas value is above 100 19 | else: 20 | GPIO.output(led_pin, GPIO.LOW) # Turn off the LED otherwise 21 | 22 | time.sleep(1) # Delay one second before reading the next value 23 | 24 | except KeyboardInterrupt: 25 | GPIO.cleanup() 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 mahdieslaminet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Firedetectionsensor 2 | 3 | 4 | 5 | 6 | این کد به زبان پایتون برای استفاده از Raspberry Pi و کتابخانه RPi.GPIO برای کنترل پایه‌های GPIO نوشته شده است. در زیر به توضیح هر بخش از کد می‌پردازم:وارد کردن کتابخانه‌ها:import RPi.GPIO as GPIO 7 | import timeاین بخش به شما این امکان را می‌دهد که از کتابخانه‌های RPi.GPIO و time استفاده کنید.تنظیمات اولیه:sensor_pin = 17 # پایه GPIO برای خواندن اطلاعات از سنسور 8 | led_pin = 27 # پایه GPIO برای کنترل LED 9 | 10 | GPIO.setmode(GPIO.BCM) 11 | GPIO.setup(led_pin, GPIO.OUT)در این بخش، شما پایه‌های GPIO را تعیین کرده و حالت آنها را تنظیم کرده‌اید. GPIO.setmode(GPIO.BCM) به شما این امکان را می‌دهد که از شماره GPIO به عنوان شماره پایه‌ها استفاده کنید.حلقه اصلی:try: 12 | while True: 13 | sensor_value = # خواندن مقدار آنالوگ از سنسور 14 | 15 | print(sensor_value) # چاپ مقدار آنالوگ در کنسول 16 | 17 | if sensor_value > 100: 18 | GPIO.output(led_pin, GPIO.HIGH) # روشن کردن LED اگر مقدار گاز بیشتر از 100 باشد 19 | else: 20 | GPIO.output(led_pin, GPIO.LOW) # خاموش کردن LED در غیر اینصورت 21 | 22 | time.sleep(1) # تاخیر یک ثانیه قبل از خواندن مقدار بعدی 23 | except KeyboardInterrupt: 24 | GPIO.cleanup()در این بخش، یک حلقه بی‌نهایت اجرا می‌شود که مقدار آنالوگ از سنسور خوانده شده و سپس در کنسول چاپ می‌شود. اگر مقدار گاز بیشتر از 100 باشد، LED روشن می‌شود و در غیر این صورت خاموش می‌شود.پایان حلقه و تمیز کردن GPIO:except KeyboardInterrupt: 25 | GPIO.cleanup()در صورت فشار Ctrl+C (یا متوقف شدن حلقه به هر دلیل دیگر)، با این بخش اطمینان حاصل می‌شود که GPIO پاکسازی شده و منابع اشغال شده آزاد شوند 26 | 27 | لینک ویدیو ها شامل یک ویدیوی نرم افزار و یک ویدیوی سخت افزار : 28 | https://drive.google.com/drive/folders/1IIO6Jz4lwITJ0vL1D1AQx3cwydVXZyfd?usp=sharing 29 | 30 | 31 | 32 | 33 | محمد دشتی 34 | ایلیا جهان دار 35 | سپنتا مرتضوی 36 | --------------------------------------------------------------------------------