GadhaGod
Published

Who Passed the Gas?

Sniff-out the real tooter.

BeginnerShowcase (no instructions)3,233
Who Passed the Gas?

Things used in this project

Hardware components

Gas Detection Sensor, Methane
Gas Detection Sensor, Methane
×1
Arduino Nano Every
Arduino Nano Every
×1
Graphic OLED, 128 x 64
Graphic OLED, 128 x 64
×1

Story

Read more

Schematics

methane__zRx3vsHEJj.png

Code

Methane

C/C++
String stat;
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width
#define SCREEN_HEIGHT 64 // OLED display height


#define OLED_RESET     4 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define NUMFLAKES     10

#define LOGO_HEIGHT   16
#define LOGO_WIDTH    16
static const unsigned char PROGMEM logo_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000 };

void setup() {
  Serial.begin(9600);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();

  // Clear the buffer
  display.clearDisplay();
  display.display();

  pinMode(A0, INPUT);

}

void loop() {
  display.clearDisplay();

  int methane = analogRead(A6);
  if (methane >= 320){
   display.setCursor(0,0);             

    stat = "fart";
  }
  else{
    stat = "no fart";
  }

  display.setTextSize(2);             
  display.setTextColor(SSD1306_WHITE);       
  display.setCursor(0,0);
  display.println(stat);

  display.setTextSize(2); 
  display.setTextColor(SSD1306_WHITE); 
  display.println("Gas Lvl:  " + String(methane));

  display.display();
}

Credits

GadhaGod
17 projects • 21 followers

Comments