yudha
Published © CC BY

PEMBERSIH ASAP ROKOK

mengeluarkan udara yang memiliki kadar sap tinggi secara otomatis. dan memberi tanda peringatan

BeginnerWork in progress3 hours1,003
PEMBERSIH ASAP ROKOK

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×2
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Buzzer
Buzzer
×1
MQ-2
×1
kipas
×1
power suplay
×1
Male/Male Jumper Wires
×1
sensor MQ-2
×1
kipas
×1
power suplay
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×1
LED (generic)
LED (generic)
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

obeng
korek api
rokok

Story

Read more

Schematics

20170807_161432_ebhcg8ywt9.jpg

20170811_081123_TcenwU9qiF.jpg

screenshot_5_BiBdrV3Avt.png

Code

PEMBERSIH ASAP

Java
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int redLed = 2;
int greenLed = 3;
int buzzer = 4;
int smokeA0 = A1;
int kipas = 5;
int sensorThres = 186;

void setup() {
lcd.begin(20, 4);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(smokeA0, INPUT);
pinMode(kipas, OUTPUT);
Serial.begin(9600);
}

void loop() {
  int analogSensor = analogRead(smokeA0);
  Serial.print("pin A0: ");
lcd.begin(20, 4);
pinMode(redLed, OUTPUT);
  Serial.println(analogSensor);
  lcd.setCursor(0,0);
  lcd.print("Kadar Asap = ");
  lcd.setCursor(12,0);
  lcd.print(analogSensor);

  if
  (analogSensor >=sensorThres)

  {
    digitalWrite(redLed,HIGH);
    digitalWrite(greenLed,LOW);
    digitalWrite(kipas,HIGH);
    tone(buzzer, 1000, 6000);
    lcd.setCursor(0,1);
    lcd.print("Bahaya");
    delay(500);
    lcd.setCursor(4,1);
    lcd.print("Asap");
    delay(500);
    lcd.setCursor(9,1);
    lcd.print("Rokok");
    delay(500);
  }
else
{
    digitalWrite(redLed,LOW);
    digitalWrite(greenLed,HIGH);
    digitalWrite(kipas,LOW);
    noTone(buzzer);
    lcd.setCursor(0,1);
    lcd.print("Udara");
    delay(500);
    lcd.setCursor(6,1);
    lcd.print("Ruangan");
    delay(500);
    lcd.setCursor(11,1);
    lcd.print("Aman");
    delay(500);
  }
  delay(100);
  lcd.clear();
}

PEMBERSIH ASAP

Java
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int redLed = 2;
int greenLed = 3;
int buzzer = 4;
int smokeA0 = A1;
int kipas = 5;
int sensorThres = 186;

void setup() {
lcd.begin(20, 4);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(smokeA0, INPUT);
pinMode(kipas, OUTPUT);
Serial.begin(9600);
}

void loop() {
  int analogSensor = analogRead(smokeA0);
  Serial.print("pin A0: ");
lcd.begin(20, 4);
pinMode(redLed, OUTPUT);
  Serial.println(analogSensor);
  lcd.setCursor(0,0);
  lcd.print("Kadar Asap = ");
  lcd.setCursor(12,0);
  lcd.print(analogSensor);

  if
  (analogSensor >=sensorThres)

  {
    digitalWrite(redLed,HIGH);
    digitalWrite(greenLed,LOW);
    digitalWrite(kipas,HIGH);
    tone(buzzer, 1000, 6000);
    lcd.setCursor(0,1);
    lcd.print("Bahaya");
    delay(500);
    lcd.setCursor(4,1);
    lcd.print("Asap");
    delay(500);
    lcd.setCursor(9,1);
    lcd.print("Rokok");
    delay(500);
  }
else
{
    digitalWrite(redLed,LOW);
    digitalWrite(greenLed,HIGH);
    digitalWrite(kipas,LOW);
    noTone(buzzer);
    lcd.setCursor(0,1);
    lcd.print("Udara");
    delay(500);
    lcd.setCursor(6,1);
    lcd.print("Ruangan");
    delay(500);
    lcd.setCursor(11,1);
    lcd.print("Aman");
    delay(500);
  }
  delay(100);
  lcd.clear();
}

Credits

yudha

yudha

1 project • 1 follower

Comments

Add projectSign up / Login