Dectection take 1. Fixed adaptation step. Detect based on a number of standard deviations away from the mean.

Dependencies:   SI1143 m3pi mbed

Fork of Proximity_Sensor_2_detect by MF Doom

Files at this revision

API Documentation at this revision

Comitter:
dmcohen24
Date:
Wed Jun 04 23:13:05 2014 +0000
Parent:
2:8798491332ed
Child:
4:5109cfc7cc96
Commit message:
samples from 2 Si1142 sensors

Changed in this revision

Proximity_Sensor_2LED.lib Show annotated file Show diff for this revision Revisions of this file
SI1143.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Proximity_Sensor_2LED.lib	Wed Jun 04 23:13:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/DP/code/Proximity_Sensor/#8798491332ed
--- a/SI1143.lib	Fri May 23 21:35:11 2014 +0000
+++ b/SI1143.lib	Wed Jun 04 23:13:05 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/dmcohen24/code/SI1141/#31d4e955ee92
+http://mbed.org/users/dmcohen24/code/SI1141/#a89555c4f62a
--- a/main.cpp	Fri May 23 21:35:11 2014 +0000
+++ b/main.cpp	Wed Jun 04 23:13:05 2014 +0000
@@ -1,33 +1,49 @@
+
 #include "mbed.h"
 #include "SI1143.h"
 
-SI1143 sensor(p28, p27);
-InterruptIn prox_meas(p29);
-Serial bt(p13, p14);
+//DigitalOut enable(p30);
+
+Ticker timer;
+
+I2C* i2c = new I2C(p28, p27);
 
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
 DigitalOut led4(LED4);
 
-int sense1;
+//DigitalIn s2(p29);
+
+SI1143 sensor1(i2c, p30, p29, 0x01);
+SI1143 sensor2(i2c, p25, p26, 0x02); // p25, p26
+
+//InterruptIn prox_meas(p26); //26
+
+int sense1a, sense1b, sense2a, sense2b;
 
 void meas_int(){
     led1 = 1;
-    sense1 = sensor.read_ps1();
-    bt.printf("%d\r\n",sense1);
-    sensor.clear_int();
+    sense1a = sensor1.get_ps1(1);
+    sense1b = sensor1.get_ps2(1);
+    sense2a = sensor2.get_ps1(1);
+    sense2b = sensor2.get_ps2(1);
+    printf("%d,  %d,  %d,  %d;\r\n",sense1a, sense1b, sense2a, sense2b);
+    //printf("%d\r\n",sense2);
+    led1 = 0;
 }
 
 int main()
 {   
     // Setup the baseline
-    // sensor.bias(1,10);
-    wait(3);
-    //led2 = 0;
-    prox_meas.fall(&meas_int);
-    sensor.start_ps_auto();
-    
+    //sensor1.restart(i2c, 0x01);
+    //printf("%d    ",sensor1.adrs);
+    //sensor2.restart(i2c, 0x02);
+    //printf("%d\r\n",sensor2.adrs);    
+    led2 = 0;
+    wait(1);
+    timer.attach(&meas_int, 0.01);
+
     while(1)
     {
         // Read each led sensor
@@ -35,9 +51,6 @@
                 
         //Numeriacl output through terminal
         led1 = 0;
-        //printf("%d\r\n",sense1);
-        
-        //led2 = !led2;
-        //wait(.01);
+        led2 = 0;
     }
-}
+}
\ No newline at end of file