Smoke detector sketch (analog I/O method)

The following sketch should be used for detecting smoke, based on the output captured from the MQ2 gas sensor's analog output pin. As always, avoid connecting the devices to the Arduino pins while loading the sketch.

The following code can be downloaded from the location mentioned in Chapter 1, Boot Camp. Here is the code for the smoke detector (analog I/O technique):

//**********************************************************/ // Step-1: CONFIGURE VARIABLES //**********************************************************/ int smokePin = A5;          // Analog Pin number A5                            // for connecting the smoke                              // sensor. int buzzerPin = 8;          // Digital Pin number 8 // for connecting the buzzer. //**********************************************************/ ...

Get Learn Arduino Prototyping in 10 days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.