O'Reilly logo

Learn Arduino Prototyping in 10 days by Kallol Bosu Roy Choudhuri

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. //**********************************************************/ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required