سلام
کد://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); } }


1   لایک   
				
 LinkBack URL
 About LinkBacks



					
					
					
						
  پاسخ با نقل قول