Infrared sensor test NUCLEO-L152RE Seeed

Dependencies:   Chainable_RGB_LED mbed

Fork of iPole_Bourseul by yang yuanyi

Files at this revision

API Documentation at this revision

Comitter:
yuanyi
Date:
Mon Dec 07 14:41:09 2015 +0000
Commit message:
Infrared sensor;

Changed in this revision

Chainable_RGB_LED.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b4d3e247e682 Chainable_RGB_LED.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Chainable_RGB_LED.lib	Mon Dec 07 14:41:09 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Seeed/code/Chainable_RGB_LED/#50d0a66599e1
diff -r 000000000000 -r b4d3e247e682 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 07 14:41:09 2015 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "ChainableLED.h"
+
+#define NUM_LED 1
+
+DigitalOut myled(LED1);
+DigitalIn TouchPin(D8);
+ChainableLED led(D6,D7,NUM_LED);
+InterruptIn motion(D2);
+
+int motion_detected = 0;
+
+void irq_handler(void)
+{
+    motion_detected = 1;
+}
+
+int main() {
+    uint8_t index = 0;
+    int cnt = 0;
+    motion.rise(&irq_handler);
+    while(1) {
+         
+//        myled = 1; // LED is ON
+//        wait(0.2); // 200 ms
+//        myled = 0; // LED is OFF
+//        wait(1.0); // 1 sec
+          int touch_value=TouchPin.read();
+          
+          //if(touch_value==1){
+          if(motion_detected){
+          //led.setColorHSB(0,hue,1.0,0.5);
+          cnt++;
+          motion_detected=0;
+          printf("Hello! I've detected %d times since reset\n", cnt);
+          printf("\r\n");
+          // generate random RGB values for LED's
+          uint8_t R = rand();
+          uint8_t G = rand();
+          uint8_t B = rand();
+          
+          // print message to terminal
+          printf("index = %d, R=%x,G=%x,B=%x,",index,R,G,B);
+          printf("\r\n");
+          // ChainableLED.setColorRGB(index_of_led, red, green, blue)
+          led.setColorRGB(index++, R, G, B);    // increase brightness cascade down chain of LED's
+          index = ((index+1) % NUM_LED);              // cycle through LED's
+          //wait(1);
+          }
+    }
+}
diff -r 000000000000 -r b4d3e247e682 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 07 14:41:09 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b
\ No newline at end of file