ASensor
 All Classes Functions Pages
MagnetSensor.h
1 #pragma once
2 /*
3  ASensor - Sensor library. Can be used standalone or in conjunction with AWind library
4  Copyright (C)2015 Andrei Degtiarev. All right reserved
5 
6  You can always find the latest version of the library at
7  https://github.com/AndreiDegtiarev/ASensor
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the MIT license.
11  Please see the included documents for further information.
12 */
14 class MagnetSensor : public ISensor
15 {
16  int _port;
17 public:
18  MagnetSensor(int port)
19  {
20  _port=port;
21  }
22  const __FlashStringHelper* Name()
23  {
24  return F("Magnet");
25  }
26  float LowMeasurementLimit()
27  {
28  return -1;
29  }
30  float HighMeasurementLimit()
31  {
32  return 2;
33  }
34  int Precission()
35  {
36  return 0;
37  }
38  bool Measure(float &data)
39  {
40  data=(int)(analogRead(_port)>500?1:0);
41  return true;
42  }
43 };
Analogue magnet sensor. No any external libraries are neccesary. Details to member functions see ISen...
Definition: MagnetSensor.h:14