jumozisan

Fork of colorSensor by yusuke takahashi

Committer:
yusuke_robocup
Date:
Mon Sep 02 13:09:42 2013 +0000
Revision:
1:86532e86498d
Parent:
0:7269a89e1d57
Child:
2:6692f0d33ca2
tuika

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akudohune 0:7269a89e1d57 1 #include "mbed.h"
akudohune 0:7269a89e1d57 2 #include "ColorSensor.h"
akudohune 0:7269a89e1d57 3
yusuke_robocup 1:86532e86498d 4 ColorSensor color(p20, p17, p18, p19, 10);
akudohune 0:7269a89e1d57 5 //ColorSensor color = ColorSensor();
akudohune 0:7269a89e1d57 6 Serial pc(USBTX, USBRX); // tx, rx
akudohune 0:7269a89e1d57 7
akudohune 0:7269a89e1d57 8 int main()
akudohune 0:7269a89e1d57 9 {
akudohune 0:7269a89e1d57 10 unsigned R, G, B;
yusuke_robocup 1:86532e86498d 11 double color_sum;
yusuke_robocup 1:86532e86498d 12 double redp,greenp,bluep;
akudohune 0:7269a89e1d57 13 //pc.baud(115200);
akudohune 0:7269a89e1d57 14 while(1)
akudohune 0:7269a89e1d57 15 {
akudohune 0:7269a89e1d57 16 color.getRGB(R, G, B);
yusuke_robocup 1:86532e86498d 17
yusuke_robocup 1:86532e86498d 18 color_sum = (R * 0.65) + G + (B * 1.3);
yusuke_robocup 1:86532e86498d 19
yusuke_robocup 1:86532e86498d 20 redp = (double)(R * 0.65)/color_sum * 100;
yusuke_robocup 1:86532e86498d 21 greenp = (double)G/color_sum * 100;
yusuke_robocup 1:86532e86498d 22 bluep = (double)(B * 1.3)/color_sum * 100;
yusuke_robocup 1:86532e86498d 23
yusuke_robocup 1:86532e86498d 24 pc.printf("%lf %lf %lf\n", redp, greenp, bluep);
akudohune 0:7269a89e1d57 25 /*
akudohune 0:7269a89e1d57 26 switch(color.judge()){
akudohune 0:7269a89e1d57 27 case RED: pc.printf("RED\n"); break;
akudohune 0:7269a89e1d57 28 case GREEN: pc.printf("GREEN\n"); break;
akudohune 0:7269a89e1d57 29 case BLUE: pc.printf("BLUE\n"); break;
akudohune 0:7269a89e1d57 30 default: break;
akudohune 0:7269a89e1d57 31 }
akudohune 0:7269a89e1d57 32 */
yusuke_robocup 1:86532e86498d 33 //wait_ms(5);
akudohune 0:7269a89e1d57 34 }
akudohune 0:7269a89e1d57 35 }