Use IR Gesture Click which is based on 'APDS-9960' To learn more about IR Gesture key, please refer to "https://shop.mikroe.com/click/hmi/ir-gesture"
Diff: main.cpp
- Revision:
- 0:55184eb43f43
- Child:
- 1:d5115a30c51d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 03 15:44:37 2017 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "glibr.h" + +glibr GSensor(D14,D15); +Serial pc(USBTX, USBRX); + +int isr_flag = 0; + +int main(void) +{ + + if ( GSensor.ginit() ) { + pc.printf("APDS-9960 initialization complete\r\n"); + } else { + pc.printf("Something went wrong during APDS-9960 init\r\n"); + return -1; + } + + // Start running the APDS-9960 gesture sensor engine + if ( GSensor.enableGestureSensor(true) ) { + pc.printf("Gesture sensor is now running\r\n"); + } else { + pc.printf("Something went wrong during gesture sensor init!\r\n"); + return -1; + } + + while(1) { + //pc.printf(".....\r\n"); + if ( GSensor.isGestureAvailable() ) { + switch ( GSensor.readGesture() ) { + case DIR_UP: + pc.printf("UP\r\n"); + break; + case DIR_DOWN: + pc.printf("DOWN\r\n"); + break; + case DIR_LEFT: + pc.printf("LEFT\r\n"); + break; + case DIR_RIGHT: + pc.printf("RIGHT\r\n"); + break; + case DIR_NEAR: + pc.printf("NEAR\r\n"); + break; + case DIR_FAR: + pc.printf("FAR\r\n"); + break; + default: + pc.printf("NONE\r\n"); + break; + } + } + } +} \ No newline at end of file