Board logo

標題: analogRead() [打印本頁]

作者: tonyh    時間: 2019-2-10 10:52     標題: analogRead()

[attach]5895[/attach]

[attach]5896[/attach]
  1. int sensorPin=A0;
  2. int sensorValue;
  3. int buzzerPin=13;
  4. //int temp;

  5. void setup()
  6. {
  7.   Serial.begin(9600);
  8.   pinMode(buzzerPin,OUTPUT);
  9. }

  10. void loop()
  11. {
  12.   sensorValue=analogRead(sensorPin);
  13.   Serial.println(sensorValue);
  14.   //temp=166*((float)(sensorValue-19)/339)-41;
  15.   //Serial.println(temp);
  16.   if(sensorValue>300)
  17.     digitalWrite(buzzerPin,HIGH);
  18.   else
  19.     digitalWrite(buzzerPin,LOW);
  20.   delay(100);
  21. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2