![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
MQ-7 Gas Sensor demo
Dependencies: mbed
Fork of Lab4_4180 by
Diff: MQ7.h
- Revision:
- 0:ff650029fdf8
diff -r 000000000000 -r ff650029fdf8 MQ7.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MQ7.h Mon Oct 31 21:59:53 2016 +0000 @@ -0,0 +1,34 @@ + +#ifndef MQ7_H +#define MQ7_H + +#include "mbed.h" + +// Interface to control an MQ-7 (Carbon Monoxide) sensor + +class MQ7 { +public: + + /** Create interfaces with gas sensor module + * + * @param alr A DigitalIn, alarm output to microcontroller + * @param hsw A PwmOut, heat switch input from microcontroller, active low + */ + MQ7(PinName alr, PinName hsw) : _alr(alr), _hsw(hsw){} + + int getAlarm(){ + return _alr.read(); + } + + void setHeat(float voltage){ + _hsw.write(voltage); + } + + +protected: + DigitalIn _alr; + PwmOut _hsw; + +}; + +#endif \ No newline at end of file