-
Notifications
You must be signed in to change notification settings - Fork 0
/
IDMS.h
84 lines (79 loc) · 2.1 KB
/
IDMS.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* IDMS.h - Infrared Distance Measuring Sensor Library
*
* Author: Márcio Pessoa <marcio.pessoa@gmail.com>
* Contributors: none
*
* Sensor technical specification
* GP2Y0A21YK0F (default)
* Range: 10cm ~ 80cm
* Connector: 3-JST
* This SHARP distance sensor bounces IR off objects to determine how far
* away they are. It returns an analog voltage that can be used to
* determine how close the nearest object is.
* The analog voltage out will range from 3V when an object is only
* 4" (10 cm) away and 0.4V when the object is 32" (80 cm) away.
*
* Front view
* ╭───┬┬───────╮
* │ o ││ 0 │
* ╰───┴┼──┬────╯
* └──┘
* 1 2 3
*
* 1 - Signal
* 2 - GND
* 3 - Vcc
*
* GP2Y0A02YK
* Range: 20cm ~ 150cm
* Connector: 3-JST
* This SHARP distance sensor bounces IR off objects to determine how far
* away they are. It returns an analog voltage that can be used to
* determine how close the nearest object is.
* **** The analog voltage out will range from 3V when an object is only
* 4" (10 cm) away and 0.4V when the object is 32" (80 cm) away. **** Need corretion
*
* Front view
* ╭───╮ ╭───╮
* │ o ╞═╡ O │
* ╰───┼─┼───╯
* └─┘
* 1 2 3
*
* 1 - Signal
* 2 - GND
* 3 - Vcc
*
* GP2Y0A41
*
* GP2Y0A60SZLF
*
* GP2Y0D810Z0F
* Range: 2cm ~ 10cm
*
* Change log
* 2015-05-14
* Improvement: Library renamed from Infrared to IDMS to solve library
* name conflict with oficial Arduino libraries.
*
* 2015-05-14
* Experimental version.
*/
#ifndef IDMS_h
#define IDMS_h
#include "Arduino.h"
#define GP2Y0A21YK0F 0
#define GP2Y0A02YK 1
class IDMS
{
public:
IDMS();
void attach(byte pin);
void type(byte sensor_type = GP2Y0A21YK0F);
float read();
private:
byte _pin;
byte _type;
int _range;
};
#endif