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
main.cpp
- Committer:
- yusuke_robocup
- Date:
- 2013-09-02
- Revision:
- 1:86532e86498d
- Parent:
- 0:7269a89e1d57
File content as of revision 1:86532e86498d:
#include "mbed.h" #include "ColorSensor.h" 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); 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; case GREEN: pc.printf("GREEN\n"); break; case BLUE: pc.printf("BLUE\n"); break; default: break; } */ //wait_ms(5); } }