Dog Feeder IR sensor storage measuring system

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Iadri
Date:
Tue Jan 26 13:26:46 2016 +0000
Parent:
2:6cb4b93e2b74
Commit message:
Final

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6cb4b93e2b74 -r 01f6b6659073 main.cpp
--- a/main.cpp	Tue Jan 26 10:09:54 2016 +0000
+++ b/main.cpp	Tue Jan 26 13:26:46 2016 +0000
@@ -1,26 +1,27 @@
 #include "mbed.h"
 
-Serial pc(USBTX, USBRX);
+//Serial pc(USBTX, USBRX);
 
 AnalogIn photores(A0);
-//DigitalIn photores(D5);
 DigitalIn button(SW2);
 DigitalOut IRled(D7);
 DigitalOut PiSign(D6);
 DigitalOut ledred(LED_RED);
-DigitalIn PiRead(A1);
+DigitalIn PiRead(D5);
 
 Ticker StorageChecker;
 
-const double ticktime = 1;
-double light = photores;
-double pi = PiRead;
+const double ticktime = 2;
+double light;
+double pi;
 
 
 void StorageCheck()
 {
     IRled = 1;
     wait_us(100);
+    light = photores;
+    pi = PiRead;
     if(light >= 0.15) {
         ledred = 0;
         PiSign = 1;
@@ -28,17 +29,15 @@
         ledred = 1;
         PiSign = 0;
     }
-    pc.printf("Photo = %0.10f \n\r", light);
-    pc.printf("PiRead = %0.10f \n\r", pi);
 }
 
 int main()
 {
-    pc.baud(9600);
+    //pc.baud(9600);
     ledred = 1;
     StorageChecker.attach(&StorageCheck, ticktime);
     while (true) {
         IRled = 0;
-        pc.printf("PiRead = %0.10f \n\r", pi);
+        sleep();
     }
 }
\ No newline at end of file