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

main.cpp

Committer:
1050186
Date:
2016-04-19
Revision:
2:27f94c9a29ec
Parent:
1:a4c6fbb79eba

File content as of revision 2:27f94c9a29ec:

#include "mbed.h"
#include "SI1143.h"

SI1143 sensor(I2C_SDA , I2C_SCL);

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);

int main()
{
    int sense1,sense2,sense3;
    
    printf("SI1143 Gesture Sensor setting...\n");
    // Setup the baseline
    sensor.bias(1,5);
    wait(1.0);
    
    printf("Sensor start!\n");
    while(1)
    {
        // Read each led sensor
        sense1 = sensor.get_ps1(1);
        sense2 = sensor.get_ps2(1);
        sense3 = sensor.get_ps3(1);
        
        // Can be changed for different sensitivity
        if (sense1 > 80 || sense2 > 80 || sense3 > 80)
        {
            if (sense1 > sense2 && sense1 > sense3)
            {
                led1=1;
                led2=0;
                led3=0;
            }
            
            else if(sense2 > sense1 && sense2 > sense3)
            {
                led1=0;
                led2=1;
                led3=0;
            }
            
            else if(sense3 > sense1 && sense3 > sense2)
            {
                led1=0;
                led2=0;
                led3=1;
            }
        }
        
        else
        {
            led1=0;
            led2=0;
            led3=0;
        }
        
        //Numeriacl output through terminal
        printf("%d-%d-%d\r\n",sense1,sense2,sense3);
        wait(0.05);
    }
}