Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 4:28185f157011
- Parent:
- 3:f41f244de0b3
diff -r f41f244de0b3 -r 28185f157011 main.cpp
--- a/main.cpp Fri Nov 29 12:46:05 2019 +0000
+++ b/main.cpp Fri Nov 29 14:50:24 2019 +0000
@@ -1,8 +1,8 @@
#include "mbed.h"
#include "glibr.h"
-Serial USB_link(USBTX, USBRX); // USB initialization
-
+Serial USB_link(USBTX, USBRX); // USB initialization
+PwmOut LCapt1(A2); // LEDs init
glibr capt1(D4,D5); // I²C initialization : D4 = SDA ; D5 = SCL
glibr capt2(D6,D7); // D6 = SDA ; D7 = SCL
glibr capt3(D8,D9); // D8 = SDA ; D9 = SCL
@@ -13,6 +13,10 @@
USB_link.baud(115200);
USB_link.format(8, SerialBase::None, 1);
+ // LEDs initialization
+ LCapt1.period_ms(10);
+ LCapt1.write(0.5);
+
// sensors initalization
if( (capt1.ginit())&& (capt1.enableLightSensor(true))&& (capt2.ginit())&& (capt2.enableLightSensor(true)) && (capt3.ginit())&& (capt3.enableLightSensor(true)) ) {
return true;
@@ -48,22 +52,25 @@
capt3.readAmbientLight(a[2]);
// display of color
- /*for(i=0; i<3; i++) {
- if (a[i]>100) {
- USB_link.printf("n ||");
+
+ for(i=0; i<3; i++) {
+ if (a[i]>70) {
+ USB_link.printf(" capt %d : n ||",i);
} else if (r[i] > g[i] ) {
- USB_link.printf("r ||");
+ USB_link.printf(" capt %d : r ||",i);
} else if (g[i] > r[i] ) {
- USB_link.printf("g ||");
+ USB_link.printf(" capt %d : g ||",i);
}
}
- USB_link.printf("\r\n");*/
+ USB_link.printf("\r\n");
//display of red and green variables
+ /*
for(i=0; i<3; i++) {
- USB_link.printf("Capt%d r: %hu g : %hu || ",i,r[i],g[i]);
+ USB_link.printf("Capt%d r: %2.hu g : %2.hu || ",i,r[i],g[i]);
}
USB_link.printf("\r\n");
+ */
}
return 0;
}
\ No newline at end of file