Ryo Ogata
/
jumpROBO3_1
jumozisan
Fork of colorSensor by
Revision 2:6692f0d33ca2, committed 2013-09-04
- Comitter:
- OGA
- Date:
- Wed Sep 04 02:40:18 2013 +0000
- Parent:
- 1:86532e86498d
- Commit message:
- jum---
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 86532e86498d -r 6692f0d33ca2 main.cpp --- a/main.cpp Mon Sep 02 13:09:42 2013 +0000 +++ b/main.cpp Wed Sep 04 02:40:18 2013 +0000 @@ -5,12 +5,17 @@ //ColorSensor color = ColorSensor(); Serial pc(USBTX, USBRX); // tx, rx +DigitalOut led[4] = {LED1,LED2,LED3,LED4}; +DigitalOut air[2]={p21,p22}; + int main() { unsigned R, G, B; double color_sum; double redp,greenp,bluep; //pc.baud(115200); + air[0] = 0; air[1] = 1; + while(1) { color.getRGB(R, G, B); @@ -21,7 +26,21 @@ greenp = (double)G/color_sum * 100; bluep = (double)(B * 1.3)/color_sum * 100; - pc.printf("%lf %lf %lf\n", redp, greenp, bluep); + pc.printf("R:%lf G:%lf B:%lf\n", redp, greenp, bluep); + + + if(redp >= 55){ + led[0] = 1; led[1] = 1; led[2] = 1; led[3] = 1; + air[0] = 1; air[1] = 0; + wait(0.5); + led[0] = 0; led[1] = 0; led[2] = 0; led[3] = 0; + air[0] = 0; air[1] = 1; + wait(2); + }else{ + led[0] = 0; led[1] = 0; led[2] = 0; led[3] = 0; + } + + /* switch(color.judge()){ case RED: pc.printf("RED\n"); break;