Easyuino  1.2.0
Relay.h
1 /*
2 MIT License
3 
4 Copyright (c) 2017 André Pires
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 /*
25 Relay.h
26 */
27 #ifndef _EASYUINO_RELAY_h
28 #define _EASYUINO_RELAY_h
29 
30 #include "Utilities.h"
31 #include "Device.h"
32 
33 namespace Easyuino {
34 
39  class Relay : public Device {
40 
41  private:
43  uint8_t _arduinoPin;
45  bool _isOn;
46 
47  public:
51  Relay(IN uint8_t arduinoPin);
52 
54  ~Relay();
55 
56  bool begin();
57 
62  bool begin(IN bool isNormallyClosed, IN uint8_t normallyClosedPinLevel);
63 
64  void end();
65 
67  void turnOn();
68 
70  void turnOff();
71 
73  bool isOn() const;
74 
75  };
76 
77 };
78 
79 #endif
bool begin()
Used to put the device ready to receive requests.
void end()
Used to stop the device API.
~Relay()
Destructor.
Definition: Button.h:38
Relay(IN uint8_t arduinoPin)
Constructor.
General class that provides the common API behaviour for all the devices/sensors. ...
Definition: Device.h:42
bool isOn() const
void turnOff()
Turns off the device that is connected to the relay (depends on how the begin(bool,uint8_t) was called)
void turnOn()
Turns on the device that is connected to the relay (depends on how the begin(bool,uint8_t) was called)
Relay offers a simple API to interact with relay devices.
Definition: Relay.h:39