forked from guillaume-rico/SharpIR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharpIR.h
More file actions
45 lines (30 loc) · 771 Bytes
/
SharpIR.h
File metadata and controls
45 lines (30 loc) · 771 Bytes
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
/*
SharpIR
Arduino library for retrieving distance (in cm) from the analog GP2Y0A21Y and GP2Y0A02YK
From an original version of Dr. Marcal Casas-Cartagena (marcal.casas@gmail.com)
Version : 1.0 : Guillaume Rico
Version : 1.2 : Archery2000
https://github.com/guillaume-rico/SharpIR
*/
#ifndef SharpIR_h
#define SharpIR_h
#define NB_SAMPLE 25
#define USE_MEDOFMEDIANS false
#ifdef ARDUINO
#include "Arduino.h"
#elif defined(SPARK)
#include "Particle.h"
#endif
class SharpIR
{
public:
SharpIR (int irPin, long sensorModel);
float distance();
private:
void sort(int a[], int size);
int _irPin;
long _model;
void partialSort(int a[], int min, int max);
int medianOfMedians(int a[], int size);
};
#endif