True leaf photo frame,gesture sensing APDS9960,motor fan,color LED

Dependencies:   SFE_APDS9960 mbed

Revision:
4:6dfbdf48fd16
Parent:
3:d046bb79dbbe
--- a/main.cpp	Wed Apr 20 15:30:25 2016 +0000
+++ b/main.cpp	Sat Apr 23 03:47:57 2016 +0000
@@ -1,11 +1,18 @@
-#include <mbed.h>
+#include <mbed.h> 
 #include "SparkFun_APDS9960.h"
 #include "led.h"
 
-Serial pc(P0_23,P0_25);   // TX Pin, RX Pin
+//Serial pc(P0_23,P0_25);   // TX Pin, RX Pin
+Serial pc(P0_23,P0_8); 
 I2C i2c(P0_14, P0_13); 
 SparkFun_APDS9960 apds(i2c);
 InterruptIn SparkFun_Int(P0_16);
+PwmOut Fan1(P0_9);
+PwmOut Fan2(P0_25);
+
+//Red_Left: P0.8    Blue_Right:P0.11    Green_Down:P0.15
+
+DigitalOut LED_Down(P0_15);
 
 int isr_flag = 0;
 
@@ -18,8 +25,12 @@
 
  int main()
  {
+     pc.baud(9600);
      pc.printf("Hello world!\n"); 
-     
+     Fan1 = 0;Fan2 = 0;
+     LED_Down = 1;
+     wait_ms(500); wait_ms(500); wait_ms(500); wait_ms(500); 
+     LED_Down = 0;
      SparkFun_Int.fall(&SparkFun_Interrupt);
         
      
@@ -31,7 +42,11 @@
      if (apds.enableGestureSensor(true) ) 
         printf("Gesture sensor is now running\n");
      else 
-        printf("Something went wrong during gesture sensor init!\n");
+       printf("Something went wrong during gesture sensor init!\n");
+    
+     Fan1.period(1/40);
+     Fan2.period(1/40);
+     Fan1 = 1; Fan2 = 1;
         
      while(1)
      {
@@ -47,16 +62,30 @@
     if ( apds.isGestureAvailable() ) {
     switch ( apds.readGesture() ) {
       case DIR_UP:
-        pc.printf("UP\n");
+      
+        pc.printf("Left\n");
+        if(Fan1.read() != 0.95)
+            Fan1 = 0.95;
+        if(Fan2.read() != 1)
+            Fan2 = 1;
         break;
+        
       case DIR_DOWN:
-        pc.printf("DOWN\n");
+      
+        pc.printf("Right\n");
+        if(Fan1.read()!= 1)
+            Fan1 = 1;
+        if(Fan2.read()!= 0.95)
+            Fan2 = 0.95;
+            
         break;
       case DIR_LEFT:
-        pc.printf("LEFT\n");
+        LED_Down = 0;
+        pc.printf("Down\n");
         break;
       case DIR_RIGHT:
-        pc.printf("RIGHT\n");
+        pc.printf("Up\n");
+        LED_Down = 1;
         break;
       case DIR_NEAR:
         pc.printf("NEAR\n");