Si1143 Gesture Sensor sample.

Dependencies:   SI1143 mbed

Fork of Gesture_Sensor by Guillermo Torijano

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.

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

SensorGR-PEACH
GNDGND
VIN3.3V
SCLD15
SDAD14
Committer:
1050186
Date:
Tue Apr 19 02:43:43 2016 +0000
Revision:
2:27f94c9a29ec
Parent:
1:a4c6fbb79eba
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GAT27 0:03bf686bd26a 1 #include "mbed.h"
GAT27 0:03bf686bd26a 2 #include "SI1143.h"
GAT27 0:03bf686bd26a 3
1050186 2:27f94c9a29ec 4 SI1143 sensor(I2C_SDA , I2C_SCL);
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
1050186 2:27f94c9a29ec 14 printf("SI1143 Gesture Sensor setting...\n");
GAT27 0:03bf686bd26a 15 // Setup the baseline
GAT27 1:a4c6fbb79eba 16 sensor.bias(1,5);
1050186 2:27f94c9a29ec 17 wait(1.0);
GAT27 0:03bf686bd26a 18
1050186 2:27f94c9a29ec 19 printf("Sensor start!\n");
GAT27 0:03bf686bd26a 20 while(1)
GAT27 0:03bf686bd26a 21 {
GAT27 0:03bf686bd26a 22 // Read each led sensor
GAT27 1:a4c6fbb79eba 23 sense1 = sensor.get_ps1(1);
GAT27 1:a4c6fbb79eba 24 sense2 = sensor.get_ps2(1);
GAT27 1:a4c6fbb79eba 25 sense3 = sensor.get_ps3(1);
GAT27 0:03bf686bd26a 26
GAT27 0:03bf686bd26a 27 // Can be changed for different sensitivity
GAT27 0:03bf686bd26a 28 if (sense1 > 80 || sense2 > 80 || sense3 > 80)
GAT27 0:03bf686bd26a 29 {
GAT27 0:03bf686bd26a 30 if (sense1 > sense2 && sense1 > sense3)
GAT27 0:03bf686bd26a 31 {
GAT27 0:03bf686bd26a 32 led1=1;
GAT27 0:03bf686bd26a 33 led2=0;
GAT27 0:03bf686bd26a 34 led3=0;
GAT27 0:03bf686bd26a 35 }
GAT27 0:03bf686bd26a 36
GAT27 0:03bf686bd26a 37 else if(sense2 > sense1 && sense2 > sense3)
GAT27 0:03bf686bd26a 38 {
GAT27 0:03bf686bd26a 39 led1=0;
GAT27 0:03bf686bd26a 40 led2=1;
GAT27 0:03bf686bd26a 41 led3=0;
GAT27 0:03bf686bd26a 42 }
GAT27 0:03bf686bd26a 43
GAT27 0:03bf686bd26a 44 else if(sense3 > sense1 && sense3 > sense2)
GAT27 0:03bf686bd26a 45 {
GAT27 0:03bf686bd26a 46 led1=0;
GAT27 0:03bf686bd26a 47 led2=0;
GAT27 0:03bf686bd26a 48 led3=1;
GAT27 0:03bf686bd26a 49 }
GAT27 0:03bf686bd26a 50 }
GAT27 0:03bf686bd26a 51
GAT27 0:03bf686bd26a 52 else
GAT27 0:03bf686bd26a 53 {
GAT27 0:03bf686bd26a 54 led1=0;
GAT27 0:03bf686bd26a 55 led2=0;
GAT27 0:03bf686bd26a 56 led3=0;
GAT27 0:03bf686bd26a 57 }
GAT27 0:03bf686bd26a 58
GAT27 0:03bf686bd26a 59 //Numeriacl output through terminal
GAT27 0:03bf686bd26a 60 printf("%d-%d-%d\r\n",sense1,sense2,sense3);
1050186 2:27f94c9a29ec 61 wait(0.05);
GAT27 0:03bf686bd26a 62 }
GAT27 0:03bf686bd26a 63 }