Components and supplies
Arduino Nano Every
Graphic OLED, 128 x 64
Gas Detection Sensor, Methane
Project description
Code
Methane
c_cpp
1String stat; 2#include <SPI.h> 3#include <Wire.h> 4#include <Adafruit_GFX.h> 5#include <Adafruit_SSD1306.h> 6 7#define SCREEN_WIDTH 128 // OLED display width 8#define SCREEN_HEIGHT 64 // OLED display height 9 10 11#define OLED_RESET 4 12Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 13 14#define NUMFLAKES 10 15 16#define LOGO_HEIGHT 16 17#define LOGO_WIDTH 16 18static const unsigned char PROGMEM logo_bmp[] = 19{ B00000000, B11000000, 20 B00000001, B11000000, 21 B00000001, B11000000, 22 B00000011, B11100000, 23 B11110011, B11100000, 24 B11111110, B11111000, 25 B01111110, B11111111, 26 B00110011, B10011111, 27 B00011111, B11111100, 28 B00001101, B01110000, 29 B00011011, B10100000, 30 B00111111, B11100000, 31 B00111111, B11110000, 32 B01111100, B11110000, 33 B01110000, B01110000, 34 B00000000, B00110000 }; 35 36void setup() { 37 Serial.begin(9600); 38 39 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 40 Serial.println(F("SSD1306 allocation failed")); 41 for(;;); 42 } 43 display.display(); 44 45 // Clear the buffer 46 display.clearDisplay(); 47 display.display(); 48 49 pinMode(A0, INPUT); 50 51} 52 53void loop() { 54 display.clearDisplay(); 55 56 int methane = analogRead(A6); 57 if (methane >= 320){ 58 display.setCursor(0,0); 59 60 stat = "fart"; 61 } 62 else{ 63 stat = "no fart"; 64 } 65 66 display.setTextSize(2); 67 display.setTextColor(SSD1306_WHITE); 68 display.setCursor(0,0); 69 display.println(stat); 70 71 display.setTextSize(2); 72 display.setTextColor(SSD1306_WHITE); 73 display.println("Gas Lvl: " + String(methane)); 74 75 display.display(); 76}
Methane
c_cpp
1String stat; 2#include <SPI.h> 3#include <Wire.h> 4#include <Adafruit_GFX.h> 5#include <Adafruit_SSD1306.h> 6 7#define SCREEN_WIDTH 128 // OLED display width 8#define SCREEN_HEIGHT 64 // OLED display height 9 10 11#define OLED_RESET 4 12Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 13 14#define NUMFLAKES 10 15 16#define LOGO_HEIGHT 16 17#define LOGO_WIDTH 16 18static const unsigned char PROGMEM logo_bmp[] = 19{ B00000000, B11000000, 20 B00000001, B11000000, 21 B00000001, B11000000, 22 B00000011, B11100000, 23 B11110011, B11100000, 24 B11111110, B11111000, 25 B01111110, B11111111, 26 B00110011, B10011111, 27 B00011111, B11111100, 28 B00001101, B01110000, 29 B00011011, B10100000, 30 B00111111, B11100000, 31 B00111111, B11110000, 32 B01111100, B11110000, 33 B01110000, B01110000, 34 B00000000, B00110000 }; 35 36void setup() { 37 Serial.begin(9600); 38 39 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 40 Serial.println(F("SSD1306 allocation failed")); 41 for(;;); 42 } 43 display.display(); 44 45 // Clear the buffer 46 display.clearDisplay(); 47 display.display(); 48 49 pinMode(A0, INPUT); 50 51} 52 53void loop() { 54 display.clearDisplay(); 55 56 int methane = analogRead(A6); 57 if (methane >= 320){ 58 display.setCursor(0,0); 59 60 stat = "fart"; 61 } 62 else{ 63 stat = "no fart"; 64 } 65 66 display.setTextSize(2); 67 display.setTextColor(SSD1306_WHITE); 68 display.setCursor(0,0); 69 display.println(stat); 70 71 display.setTextSize(2); 72 display.setTextColor(SSD1306_WHITE); 73 display.println("Gas Lvl: " + String(methane)); 74 75 display.display(); 76}
Downloadable files
untitled
untitled
Comments
Only logged in users can leave comments
GadhaGod
1 Followers
•12 Projects
5
1
Who Passed the Gas? | Arduino Project Hub
ShreyanR
5 years ago
Very interesting project. This happens to everyone - they get blamed for a fart that they did not release.