partie Capteur de couleur non fonctionnel
Dependencies: mbed GroveColourSensor
Revision 0:96895997d17b, committed 2018-12-21
- Comitter:
- Melmino
- Date:
- Fri Dec 21 11:08:43 2018 +0000
- Commit message:
- non fonctionnel
Changed in this revision
diff -r 000000000000 -r 96895997d17b GroveColourSensor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GroveColourSensor.lib Fri Dec 21 11:08:43 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/components/code/GroveColourSensor/#56d6b711b8c7
diff -r 000000000000 -r 96895997d17b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 21 11:08:43 2018 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" +#include "GroveColourSensor.hpp" + +//I2C i2c(p9, p10); + +int main() { + + BusOut myleds(LED1, LED2, LED3, LED4); + GroveColourSensor colorSensor(p9, p10); + + + int i=0; + uint16_t colourValue; + unsigned colour; + char col[6]; + + int green, red, blue; + + colorSensor.powerUp(); + + while(1) { + for (colour = GroveColourSensor::GREEN; colour < GroveColourSensor::NUM_COLORS; colour++) { + colourValue = colorSensor.readColour(colour); + + } + + while(colourValue>0) + { + col[i]=colourValue%2; + colourValue=colourValue/2; + i++; + } + + green = col[1] * 256 + col[0]; + red = col[3] * 256 + col[2]; + blue = col[5] * 256 + col[4]; + + if (red>=green && red>=blue) { + myleds = 2; + wait(0.5); + } + + else if (green>=red && green>=blue) { + myleds = 4; + wait(0.5); + } + else if(blue>=red && blue>=green) { + myleds = 8; + wait(0.5); + } + // else myleds = i; + else { + myleds = 15; + wait(0.5); + } + } + //colorSensor.powerDown(); + + } +
diff -r 000000000000 -r 96895997d17b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 21 11:08:43 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file