Skip to content

Instantly share code, notes, and snippets.

@penpencool
Created May 30, 2018 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penpencool/04e68d07e798564f6b468c155f52560e to your computer and use it in GitHub Desktop.
Save penpencool/04e68d07e798564f6b468c155f52560e to your computer and use it in GitHub Desktop.
/*
Example By ArduinoAll
https://www.arduinoall.com/p/2061
*/
int flame = A0; // ต่อขาเซนเซอร์เปลวไฟกับขา A0
int Beep = 9; // ต่อ buzzer กับขา 9
int val = 0; // ตัวแปรสำหรับอ่านค่าจากเซนเซอร์เปลวไฟ
void setup()
{
pinMode(Beep, OUTPUT);
pinMode(flame, INPUT);
Serial.begin(9600);//
}
void loop()
{
val = analogRead(flame); //อ่านค่าเซนเซอร์เปลวไฟ
Serial.println(val);// แสดงค่าออกทาง Serial Monitor
if (val >= 600) // ถ้าค่ามากกว่า 600 ให้แสดงเสียงเตือน
{
digitalWrite(Beep, HIGH);
} else
{
digitalWrite(Beep, LOW);
}
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment