نمایش نتایج: از 1 به 5 از 5
Like Tree1 لایک
  • 1 Post By dm800vpr

موضوع: راهنمایی درباره نحوه کار با ماژول سنسور تشخیص آتش و شعله - سنسور مادون قرمز

Hybrid View

  1. #1
    مدیر اصلی
    تاریخ عضویت
    Aug 2012
    محل سکونت
    ایران
    نوشته ها
    440
    سلام
    کد:
    //You may copy, alter and reuse this code in any way you like but please leave reference to HobbyComponents.com in your comments if you redistribute this code.
    //This code is modified by Ahlskog Niki & Borgström Anders
    
    //SENSOR PINOUT:
    PIN 1: Analogue out
    PIN 2: Ground
    PIN 3: +5V
    PIN 4: Digital out
    
    #define FLAME_DETECT_ANA A0 // Select the input pin for the flame detectors analogue output.
    #define FLAME_DETC_DIO 2 // Select the input pin for the flame detectors digital output.
    
    int led = 8; // Select the input pin for the led
    
    void setup() // Initialize serial and DIO
    {
    
    Serial.begin(9600); // Setup the serial port for displaying the status of the sensor
    pinMode(led, OUTPUT);
    
    pinMode(FLAME_DETC_DIO, INPUT); // Configure the DIO pin the sensors digital output will be connected to
    }
    
    void loop() // Main program loop
    {
    
    Serial.print("Sensor Value: "); // Read the sensors analogue output and send it to the serial port
    Serial.print(analogRead(FLAME_DETECT_ANA));
    if (digitalRead(FLAME_DETC_DIO)) // Read the status of the sensors digital output and if it is high then send an alert to the UART and the led is lighten
    {
    Serial.println(" FLAME DETECTED!");
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    
    }else // Otherwise the there is no alert and the led is shut down
    {
    Serial.println();
    digitalWrite(led, LOW);
    }
    }

  2. #2
    Junior Member
    تاریخ عضویت
    Oct 2015
    نوشته ها
    24
    من کد رو به صورت زیر عوض میکنم
    کد:
    //You may copy, alter and reuse this code in any way you like but please leave reference to HobbyComponents.com in your comments if you redistribute this code. //This code is modified by Ahlskog Niki & Borgström Anders //SENSOR PINOUT: #define FLAME_DETECT_ANA A0 // Select the input pin for the flame detectors analogue output. #define FLAME_DETC_DIO 2 // Select the input pin for the flame detectors digital output. int led = 8; // Select the input pin for the led void setup() // Initialize serial and DIO { Serial.begin(9600); // Setup the serial port for displaying the status of the sensor pinMode(led, OUTPUT); pinMode(FLAME_DETC_DIO, INPUT); // Configure the DIO pin the sensors digital output will be connected to } void loop() // Main program loop { Serial.print("Sensor Value: "); // Read the sensors analogue output and send it to the serial port Serial.print(analogRead(FLAME_DETECT_ANA)); delay(1000); if (!digitalRead(FLAME_DETC_DIO)) // Read the status of the sensors digital output and if it is high then send an alert to the UART and the led is lighten { Serial.println(" FLAME DETECTED!"); digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); }else // Otherwise the there is no alert and the led is shut down { Serial.println(); digitalWrite(led, LOW); } }
    دلیلش اینه ماژول سایت فقط D0 داره و این کد برای A0 D0 نوع دیگری 4 پایه ماژول هست نه 3 پایه
    در نتیجه همیشه flame detected میده
    که من یه delay اضافه کردم و قسمت digitalRead(FLAME_DETC_DIO) رو not کردم

    توضیحات تکمیلی
    کد:
    How it works: The flame sensor is very sensitive to IR wavelength at 760 nm ~ 1100 nm light. Analog output (A0): Real-time output voltage signal on the thermal resistance. Digital output (D0): When the temperature reaches a certain threshold, the output high and low signal threshold adjustable via potentiometer
    .
    لایک کردن

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO