1. #define Aout A0 //MQ-135 AO 接 Arduino Uno A0 2. 3. int temp = 0; //臨時變量,存儲A0讀取的數(shù)據(jù) 4. 5. void setup() { 6. // put your setup code here, to run once: 7. Serial.begin(9600);//定義波特率 8. pinMode(Aout, INPUT);//定義A0為INPUT模式 9. } 10. 11. void loop() { 12. // put your main code here, to run repeatedly: 13. temp = analogRead(Aout); //讀取A0的模擬數(shù)據(jù) 14. Serial.println(temp); //串口輸出temp的數(shù)據(jù) 15. delay(600); //延時500毫秒 16. }
|