Danny van den Brande
Published © CC BY-SA

Arduino Carbon Monoxide detector Alarm with relay

My device is just a prototype to show you how to the monoxide detector.

BeginnerWork in progress1 hour3,737
Arduino Carbon Monoxide detector Alarm with relay

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Buzzer
Buzzer
×1
Keyes 3 color RGB Ky-016
×1
mq9 Carbon Monoxide Sensor
×1
1 Channel relay Ky-019
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

Schematic

This was my very first project en schematic. I will make a new schematic. this one is a bit messy

Code

GasALARM_with_relay.ino

Arduino
My first arduino code.
//Author: Danny van den Brande
//ArduinoSensors.nl
int relay = 10; // relay turns trigger signal - active high;
int buzzer = 8 ;// pin for buzzer alarm
const int analogInPin = A0;  // Analoge Input 
const int ledPin = 13; // RED LED
const int ledPin2 = 12; // BLUE LED 
const int ledPin3 = 11; // GREEN LED

int sensorValue = 0;        

void setup() {
  
  Serial.begin(9600); 
  pinMode(ledPin, OUTPUT);      // zet de digitale pin als output
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode (buzzer, OUTPUT) ;    
  pinMode (relay, OUTPUT); 
}

void loop() {
  
  sensorValue = analogRead(analogInPin);            
  // bepaal wanneer alarm afgaat
  if (sensorValue >= 100)
  {
    digitalWrite(ledPin, HIGH);  
    digitalWrite(ledPin3, LOW);  
    digitalWrite (buzzer, HIGH) ;// buzz 
    delay(50);
    digitalWrite (buzzer, LOW) ;
    delay(50);
    digitalWrite (buzzer, HIGH) ;    
    delay(50);
    digitalWrite (buzzer, LOW) ;
    delay(50);
    digitalWrite (buzzer, HIGH) ;        
    delay(600);
    digitalWrite (buzzer, LOW) ;
    delay(600);
    digitalWrite (buzzer, HIGH) ;    
    delay(50);
    digitalWrite (buzzer, LOW) ;
    delay(50);
    digitalWrite (buzzer, HIGH) ;    
    delay(50);
    digitalWrite (buzzer, LOW) ;
    delay(50);
    digitalWrite (buzzer, HIGH) ;    
    delay(300);
    digitalWrite (buzzer, LOW) ;
    delay(300);
    digitalWrite (buzzer, HIGH) ;    
    delay(50);
    digitalWrite (buzzer, LOW) ;
    delay(50);
    digitalWrite (buzzer, HIGH) ;    
    delay(50);
    digitalWrite (buzzer, LOW) ;
    delay(50);
    digitalWrite (buzzer, HIGH) ;
    delay(50);
    digitalWrite (buzzer, LOW) ;
    delay(50);
    

    digitalWrite (relay, LOW); 
  

  }
  else
  {
    digitalWrite(ledPin3, HIGH);    
    digitalWrite(ledPin, LOW);        
    digitalWrite (buzzer, LOW) ;
    digitalWrite (relay, HIGH); // relay conduction;
  }

 

  
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);     

  
  
  delay(10);                     
}

Credits

Danny van den Brande

Danny van den Brande

36 projects • 72 followers
"Hello world."

Comments