Advertisement
AnindyaBiswas

MQ2

Mar 3rd, 2023
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int mq2Pin = A1;
  2. int dig = 13;
  3.  
  4. void setup() {
  5.   // put your setup code here, to run once:
  6.   pinMode(mq2Pin, INPUT);
  7.   pinMode(13, INPUT);
  8.   Serial.begin(9600);
  9. }
  10.  
  11. void loop() {
  12.   // put your main code here, to run repeatedly:
  13.   int analVal = analogRead(mq2Pin);
  14.   int digiVal = digitalRead(dig);
  15.  
  16.   Serial.print("Analog Value = ");
  17.   Serial.print(analVal);
  18.   Serial.print("    Digital Value = ");
  19.   Serial.println(digiVal);
  20.   delay(500);
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement