ºÒ²ÉÀ» °¨ÁöÇÒ ¼ö ÀÖ´Â ¼¾¼ÀÔ´Ï´Ù. Àû¿Ü¼±À» ÀÌ¿ëÇÏ¿© ºÒ¿¡¼ ³ª´Â ºûÀ» °¨ÁöÇÒ ¼ö ÀÖÀ¸¸ç ¿ÜÇüÀº LED ó·³ »ý°å´Âµ¥ °ËÀº»öÀÔ´Ï´Ù. LED¿Í ºñ½ÁÇÏ°Ô ±ä´Ù¸®°¡ +, ªÀº´Ù¸®°¡ -±ØÀÔ´Ï´Ù.
int flame = A0; int Buzzer = 8; int val = 0;
void setup()
{ pinMode(Buzzer, OUTPUT); //Set LED as output pinMode(flame, INPUT); //Set buzzer as input Serial.begin(9600); //Set baud rate as 9600 }
void loop()
{ val = analogRead(flame); //Read the analog value Serial.println(val); //Output analog value and print it out if (val >= 600) // When analog value ¡µ600£¬buzzer make sound { digitalWrite(Buzzer, HIGH); } else
{
digitalWrite(Buzzer, LOW); } }
|