MQ-7 Gas Sensor demo

Dependencies:   mbed

Dependents:   GloboMet

Committer:
bryanbates
Date:
Mon Oct 31 22:05:29 2016 +0000
Revision:
1:6f35304675ae
Parent:
0:ff650029fdf8
MQ-7 gas sensor demo;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bryanbates 0:ff650029fdf8 1
bryanbates 0:ff650029fdf8 2 #ifndef MQ7_H
bryanbates 0:ff650029fdf8 3 #define MQ7_H
bryanbates 0:ff650029fdf8 4
bryanbates 0:ff650029fdf8 5 #include "mbed.h"
bryanbates 0:ff650029fdf8 6
bryanbates 0:ff650029fdf8 7 // Interface to control an MQ-7 (Carbon Monoxide) sensor
bryanbates 0:ff650029fdf8 8
bryanbates 0:ff650029fdf8 9 class MQ7 {
bryanbates 0:ff650029fdf8 10 public:
bryanbates 0:ff650029fdf8 11
bryanbates 0:ff650029fdf8 12 /** Create interfaces with gas sensor module
bryanbates 0:ff650029fdf8 13 *
bryanbates 0:ff650029fdf8 14 * @param alr A DigitalIn, alarm output to microcontroller
bryanbates 0:ff650029fdf8 15 * @param hsw A PwmOut, heat switch input from microcontroller, active low
bryanbates 0:ff650029fdf8 16 */
bryanbates 0:ff650029fdf8 17 MQ7(PinName alr, PinName hsw) : _alr(alr), _hsw(hsw){}
bryanbates 0:ff650029fdf8 18
bryanbates 0:ff650029fdf8 19 int getAlarm(){
bryanbates 0:ff650029fdf8 20 return _alr.read();
bryanbates 0:ff650029fdf8 21 }
bryanbates 0:ff650029fdf8 22
bryanbates 0:ff650029fdf8 23 void setHeat(float voltage){
bryanbates 0:ff650029fdf8 24 _hsw.write(voltage);
bryanbates 0:ff650029fdf8 25 }
bryanbates 0:ff650029fdf8 26
bryanbates 0:ff650029fdf8 27
bryanbates 0:ff650029fdf8 28 protected:
bryanbates 0:ff650029fdf8 29 DigitalIn _alr;
bryanbates 0:ff650029fdf8 30 PwmOut _hsw;
bryanbates 0:ff650029fdf8 31
bryanbates 0:ff650029fdf8 32 };
bryanbates 0:ff650029fdf8 33
bryanbates 0:ff650029fdf8 34 #endif