Alcohol Detector Circuit Board
อุปกรณ์
- Arduino UNO
- Alcohol detector Arduino shield from JLCPCB
- Alcohol Sensor (MQ3)
- Resistor 10K
- Resistor 1K
- 16x2 LCD
- Power Supply
- 10k POT
- LED
- LM358
- Burgstips
- Push button
Diagram
Code
#include <LiquidCrystal.h> //เรียกใช้จอLCD
LiquidCrystal lcd(12,11,5,4,3,2); //กำหนดขา
#define sensor A0
#define led 13
#define buz 9
void setup()
{
Serial.begin(9600); //ตั้งค่าการรับส่งข้อมูลที่ 9600 บิท
lcd.begin(16,2); //ให้LCDเริ่มที่ตำแหน่ง 16x2
lcd.print("Alcohol Detector");
lcd.setCursor(0,1);
lcd.print(" Circuit Digest ");
delay(2000);
pinMode(sensor, INPUT);
pinMode(buz, OUTPUT);
pinMode(led, OUTPUT);
lcd.clear();
}
void loop()
{
float adcValue=0;
for(int i=0;i<10;i++)
{
adcValue+= analogRead(sensor);
delay(10);
}
float v= (adcValue/10) * (5.0/1024.0);
float mgL= 0.67 * v;
Serial.print("BAC:");
Serial.print(mgL);
Serial.print(" mg/L");
lcd.setCursor(0,0);
lcd.print("BAC: ");
lcd.print(mgL,4);
lcd.print(" mg/L ");
lcd.setCursor(0,1);
if(mgL > 0.8)
{
lcd.print("Drunk ");
Serial.println(" Drunk");
digitalWrite(buz, HIGH);
digitalWrite(led, HIGH);
}
else
{
lcd.print("Normal ");
Serial.println(" Normal");
digitalWrite(buz, LOW);
digitalWrite(led, LOW);
}
delay(100);
}
Credit By : https://circuitdigest.com/microcontroller-projects/arduino-alcohol-detector-circuit-board
ความคิดเห็น
แสดงความคิดเห็น