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.
Fork of colorSensor by
Revision 1:86532e86498d, committed 2013-09-02
- Comitter:
- yusuke_robocup
- Date:
- Mon Sep 02 13:09:42 2013 +0000
- Parent:
- 0:7269a89e1d57
- Commit message:
- tuika
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7269a89e1d57 -r 86532e86498d main.cpp --- a/main.cpp Thu Aug 29 13:50:59 2013 +0000 +++ b/main.cpp Mon Sep 02 13:09:42 2013 +0000 @@ -1,18 +1,27 @@ #include "mbed.h" #include "ColorSensor.h" -ColorSensor color(p17, p18, p19, p20, 10); +ColorSensor color(p20, p17, p18, p19, 10); //ColorSensor color = ColorSensor(); Serial pc(USBTX, USBRX); // tx, rx int main() { unsigned R, G, B; + double color_sum; + double redp,greenp,bluep; //pc.baud(115200); while(1) { color.getRGB(R, G, B); - pc.printf("%4d %4d %4d\n", R, G, B); + + color_sum = (R * 0.65) + G + (B * 1.3); + + redp = (double)(R * 0.65)/color_sum * 100; + greenp = (double)G/color_sum * 100; + bluep = (double)(B * 1.3)/color_sum * 100; + + pc.printf("%lf %lf %lf\n", redp, greenp, bluep); /* switch(color.judge()){ case RED: pc.printf("RED\n"); break; @@ -21,6 +30,6 @@ default: break; } */ - wait_ms(500); + //wait_ms(5); } } \ No newline at end of file