Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
seifemadat
Published

DIY Gas Leak Detector and Alarm

This idea came to me because in many homes there is a gas leak and it can lead to a disaster. This idea will prevent a catastrophe from happ

BeginnerFull instructions provided1 hour252
DIY Gas Leak Detector and Alarm

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
LED Dot Matrix Display, Red
LED Dot Matrix Display, Red
×1
Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1

Software apps and online services

Arduino IDE
Arduino IDE
EasyEDA
JLCPCB EasyEDA

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

screenshot_2022-01-28_002616_m4DNSN3ZTK.png

Code

LEDMatrix

Arduino
#include <LedControl.h>
int DIN = 10;
int CS =  9;
int CLK = 8;
int SOK = 3;
int br = 13;

LedControl lc = LedControl(DIN, CLK, CS, 0);

void setup() {
  pinMode(SOK, INPUT);
  pinMode(br, OUTPUT);

  lc.shutdown(0, false);
  lc.setIntensity(0, 15);     //Adjust the brightness maximum is 15
  lc.clearDisplay(0);
}

void loop() {

  //Facial Expression
  byte smile[8] =   {0x3C,0x42,0x95,0xA1,0xA1,0x95,0x42,0x3C};
  byte sad[8] =   {0x3C,0x42,0xA5,0x91,0x91,0xA5,0x42,0x3C};
  byte AT[8] = {0x00, 0x67, 0x92, 0x92, 0xF2, 0x92, 0x00, 0x00};


  if (digitalRead(SOK) == 1)
  {
    printByte(smile);
    noTone(br);

    delay(500);

  } else /// =0
  {
    printByte(sad);
    tone(br, 400);
    delay(500);
    noTone(br);

    delay(500);
  }




}

void printByte(byte character [])
{
  int i = 0;
  for (i = 0; i < 8; i++)
  {
    lc.setRow(0, i, character[i]);
  }
}

Credits

seifemadat

seifemadat

1 project • 0 followers

Comments