
Si1143 Gesture Sensor sample.
Fork of Gesture_Sensor by
About Si1143
Si1143 is a gesture sensor and can be controlled by using the I2C.
This can be detected from the shortest 1cm up to 200cm.
Si1143 emits three infrared LED that is mounted on a substrate, and detects the movement by measuring the reflected light from the external object.
- Datasheet of Si1143
http://www.silabs.com/Support%20Documents/TechnicalDocs/Si114x.pdf
About sample program
When you hold your hand on the upper of LED1 of Si1143, LED1 (red) of GR-PEACH lights up.
When you hold your hand on the upper of LED2 of Si1143, LED2 (green) of GR-PEACH lights up.
When you hold your hand on the upper of LED3 of Si1143, LED3 (blue) of GR-PEACH lights up.
When you approach your hand to LED of Si1143, level of the LED light will output a large value.
About wiring
Sensor | GR-PEACH |
GND | GND |
VIN | 3.3V |
SCL | D15 |
SDA | D14 |
main.cpp@1:a4c6fbb79eba, 2013-10-21 (annotated)
- Committer:
- GAT27
- Date:
- Mon Oct 21 20:14:03 2013 +0000
- Revision:
- 1:a4c6fbb79eba
- Parent:
- 0:03bf686bd26a
- Child:
- 2:27f94c9a29ec
Individual reads and sample support added.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GAT27 | 0:03bf686bd26a | 1 | #include "mbed.h" |
GAT27 | 0:03bf686bd26a | 2 | #include "SI1143.h" |
GAT27 | 0:03bf686bd26a | 3 | |
GAT27 | 0:03bf686bd26a | 4 | SI1143 sensor(p28, p27); |
GAT27 | 0:03bf686bd26a | 5 | |
GAT27 | 0:03bf686bd26a | 6 | DigitalOut led1(LED1); |
GAT27 | 0:03bf686bd26a | 7 | DigitalOut led2(LED2); |
GAT27 | 0:03bf686bd26a | 8 | DigitalOut led3(LED3); |
GAT27 | 0:03bf686bd26a | 9 | |
GAT27 | 0:03bf686bd26a | 10 | int main() |
GAT27 | 0:03bf686bd26a | 11 | { |
GAT27 | 0:03bf686bd26a | 12 | int sense1,sense2,sense3; |
GAT27 | 0:03bf686bd26a | 13 | |
GAT27 | 0:03bf686bd26a | 14 | // Setup the baseline |
GAT27 | 1:a4c6fbb79eba | 15 | sensor.bias(1,5); |
GAT27 | 0:03bf686bd26a | 16 | wait(1); |
GAT27 | 0:03bf686bd26a | 17 | |
GAT27 | 0:03bf686bd26a | 18 | while(1) |
GAT27 | 0:03bf686bd26a | 19 | { |
GAT27 | 0:03bf686bd26a | 20 | // Read each led sensor |
GAT27 | 1:a4c6fbb79eba | 21 | sense1 = sensor.get_ps1(1); |
GAT27 | 1:a4c6fbb79eba | 22 | sense2 = sensor.get_ps2(1); |
GAT27 | 1:a4c6fbb79eba | 23 | sense3 = sensor.get_ps3(1); |
GAT27 | 0:03bf686bd26a | 24 | |
GAT27 | 0:03bf686bd26a | 25 | // Can be changed for different sensitivity |
GAT27 | 0:03bf686bd26a | 26 | if (sense1 > 80 || sense2 > 80 || sense3 > 80) |
GAT27 | 0:03bf686bd26a | 27 | { |
GAT27 | 0:03bf686bd26a | 28 | if (sense1 > sense2 && sense1 > sense3) |
GAT27 | 0:03bf686bd26a | 29 | { |
GAT27 | 0:03bf686bd26a | 30 | led1=1; |
GAT27 | 0:03bf686bd26a | 31 | led2=0; |
GAT27 | 0:03bf686bd26a | 32 | led3=0; |
GAT27 | 0:03bf686bd26a | 33 | } |
GAT27 | 0:03bf686bd26a | 34 | |
GAT27 | 0:03bf686bd26a | 35 | else if(sense2 > sense1 && sense2 > sense3) |
GAT27 | 0:03bf686bd26a | 36 | { |
GAT27 | 0:03bf686bd26a | 37 | led1=0; |
GAT27 | 0:03bf686bd26a | 38 | led2=1; |
GAT27 | 0:03bf686bd26a | 39 | led3=0; |
GAT27 | 0:03bf686bd26a | 40 | } |
GAT27 | 0:03bf686bd26a | 41 | |
GAT27 | 0:03bf686bd26a | 42 | else if(sense3 > sense1 && sense3 > sense2) |
GAT27 | 0:03bf686bd26a | 43 | { |
GAT27 | 0:03bf686bd26a | 44 | led1=0; |
GAT27 | 0:03bf686bd26a | 45 | led2=0; |
GAT27 | 0:03bf686bd26a | 46 | led3=1; |
GAT27 | 0:03bf686bd26a | 47 | } |
GAT27 | 0:03bf686bd26a | 48 | } |
GAT27 | 0:03bf686bd26a | 49 | |
GAT27 | 0:03bf686bd26a | 50 | else |
GAT27 | 0:03bf686bd26a | 51 | { |
GAT27 | 0:03bf686bd26a | 52 | led1=0; |
GAT27 | 0:03bf686bd26a | 53 | led2=0; |
GAT27 | 0:03bf686bd26a | 54 | led3=0; |
GAT27 | 0:03bf686bd26a | 55 | } |
GAT27 | 0:03bf686bd26a | 56 | |
GAT27 | 0:03bf686bd26a | 57 | //Numeriacl output through terminal |
GAT27 | 0:03bf686bd26a | 58 | printf("%d-%d-%d\r\n",sense1,sense2,sense3); |
GAT27 | 0:03bf686bd26a | 59 | } |
GAT27 | 0:03bf686bd26a | 60 | } |