lib Modulove
Library for building custom scripts for Modulove modules.
Loading...
Searching...
No Matches
analog_input.h
Go to the documentation of this file.
1
11#ifndef ANALOG_INPUT_H
12#define ANALOG_INPUT_H
13
14#include <Arduino.h>
15
16namespace modulove {
17
18const int MAX_INPUT = (1 << 10) - 1; // Max 10 bit analog read resolution.
19
21 public:
22 AnalogInput() {}
23 ~AnalogInput() {}
24
30 void Init(uint8_t pin) {
31 pinMode(pin, INPUT);
32 pin_ = pin;
33 }
34
39 void Process() {
40 old_read_ = read_;
41 read_ = analogRead(pin_);
42 }
43
49 inline uint16_t Read() { return read_; }
50
51 private:
52 uint8_t pin_;
53 uint16_t read_;
54 uint16_t old_read_;
55};
56
57} // namespace modulove
58
59#endif
Definition analog_input.h:20
void Process()
Read the value of the analog input.
Definition analog_input.h:39
void Init(uint8_t pin)
Initializes a analog input object.
Definition analog_input.h:30
uint16_t Read()
Get the current value of the analog input.
Definition analog_input.h:49