-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathio.h
51 lines (44 loc) · 913 Bytes
/
io.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**************************************************************************/
/*!
@file io.h
@author lisper ([email protected])
@license LGPLv3 (see license.txt)
provide some useful function make it easy to control io
Copyright (C) 2014 DFRobot
*/
class digitalOut {
public :
int pin;
digitalOut (uint8_t thePin);
void write (uint8_t value);
void operator= (int state) {
digitalWrite (pin, state);
}
};
class digitalIn {
public:
int pin;
digitalIn (uint8_t thePin);
uint8_t read ();
operator uint8_t () {
return digitalRead (pin);
}
};
class analogOut {
public:
int pin;
analogOut (uint8_t thePin);
void write (uint8_t value);
void operator= (uint8_t value) {
analogWrite (pin, value);
}
};
class analogIn {
public:
int pin;
analogIn (uint8_t thePin);
uint16_t read ();
operator uint16_t () {
return analogRead (pin);
}
};