- int sensorPin=A0;
- int sensorValue;
- int buzzerPin=13;
- //int temp;
- void setup()
- {
- Serial.begin(9600);
- pinMode(buzzerPin,OUTPUT);
- }
- void loop()
- {
- sensorValue=analogRead(sensorPin);
- Serial.println(sensorValue);
- //temp=166*((float)(sensorValue-19)/339)-41;
- //Serial.println(temp);
- if(sensorValue>300)
- digitalWrite(buzzerPin,HIGH);
- else
- digitalWrite(buzzerPin,LOW);
- delay(100);
- }
複製代碼 |