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.
Revision 2:2adef204b5ba, committed 2019-04-08
- Comitter:
- jhonatanll
- Date:
- Mon Apr 08 12:36:00 2019 +0000
- Parent:
- 1:334b40b47233
- Commit message:
- sensor color
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| scolor_TCS3200.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Feb 28 22:33:57 2019 +0000
+++ b/main.cpp Mon Apr 08 12:36:00 2019 +0000
@@ -54,7 +54,7 @@
Serial command(USBTX, USBRX);
// S0, S1, S2, S3, OUT
-scolor_TCS3200 scolor(PA_8, PB_10, PB_4, PB_5, PB_3);
+scolor_TCS3200 scolor(PA_8, PB_10, PB_4, PB_5, PA_10);
// definición de las funciones
void setup_uart();
@@ -69,7 +69,7 @@
while(1){
leer_datos();
if (cmd==CMD){}
- leer_color();
+ leer_color();
}
}
@@ -90,7 +90,10 @@
void leer_color(){
-
+ uint8_t ref;
+ uint8_t rd;
+ uint8_t gr;
+ uint8_t bl;
long red = scolor.ReadRed();
long green = scolor.ReadGreen();
@@ -99,9 +102,32 @@
printf("RED: %5d GREEN: %5d BLUE: %5d CLEAR: %5d \n ", red, green, blue, clear);
- }
+
+
+ref = (1/clear);
+rd =(((1/red)*100))/ref);
+gr =((1/green)*100))/ref;
+bl =((1/blue)*100))/ref;
-
\ No newline at end of file
+ if (rd>gr && rd>bl){
+ printf("el color es rojo");
+ }
+
+
+
+ if (bl>gr && bl>rd){
+ printf("el color es azul");
+ }
+
+
+
+
+ if (gr>rd && gr>bl){
+ printf("el color es verde");
+ }
+
+
+ }
\ No newline at end of file
--- a/scolor_TCS3200.cpp Thu Feb 28 22:33:57 2019 +0000
+++ b/scolor_TCS3200.cpp Mon Apr 08 12:36:00 2019 +0000
@@ -26,8 +26,9 @@
long scolor_TCS3200::pulsewidth() {
while(!_s_in);
+ while(_s_in);
timer.start();
- while(_s_in);
+ while(!_s_in);
timer.stop();
float pulsewidth_v = timer.read_us();
timer.reset();